Dan Van Brunt
12/01/2021, 10:58 PMstack.resolve(thingy)
work behinds the scenes?
It seems to prevent any future changes to thingy using L2 methods?Dan Van Brunt
12/01/2021, 10:58 PMconst cfDistribution = this.cfDistribution.node.defaultChild as cf.CfnDistribution
const config = stack.resolve(cfDistribution.distributionConfig)
const origins = config.origins.map((origin: cf.OriginProps) =>
origin?.originPath === `/${this.deployId}`
? {
...origin,
originCustomHeaders: [
{
headerName: 'X-Site-Root-Key',
headerValue: this.deployId,
},
],
}
: origin,
)
cfDistribution.distributionConfig = {
...cfDistribution.distributionConfig,
webAclId: settings.WAF,
origins,
}
Dan Van Brunt
12/01/2021, 11:00 PMif (props.httpApi) {
const { httpApi } = props
const apiDomain = `${httpApi.httpApiId}.execute-api.${region}.<http://amazonaws.com|amazonaws.com>`
this.cfDistribution.addBehavior('/api', new cfOrigins.HttpOrigin(apiDomain), {
allowedMethods: cf.AllowedMethods.ALLOW_ALL,
viewerProtocolPolicy: cf.ViewerProtocolPolicy.REDIRECT_TO_HTTPS,
cachePolicy: cf.CachePolicy.CACHING_DISABLED,
compress: false,
})
}
saying that an origin is missing.
What seems to have happened is the behavior is added that references an origin that doesn’t exist, since the resolve
seems to have sealed any edits to that cfDistribution.Dan Van Brunt
12/01/2021, 11:02 PMresolve
it then prevents you from exposing that underlining thing. Eg. StaticSite.cfDistribution.addBehavior()
wouldn’t work if StaticSite internally resolved ``cfDistribution`` .
Is any of this correct? How else can we accomplish our above code is not to resolve?Frank
Frank
Frank
azs
would know how many zones there are in the region. But if region is not known at build time, .resolve()
won’t be able to resolve it.Dan Van Brunt
12/01/2021, 11:54 PMDan Van Brunt
12/01/2021, 11:55 PMDan Van Brunt
12/01/2021, 11:56 PM