Complete a 3 Question Survey and Earn a re:Post Badge
Help improve AWS Support Official channel in re:Post and share your experience - complete a quick three-question survey to earn a re:Post badge!
【以下的问题经过翻译处理】 我刚刚从 AWS Solutions 中部署了一个使用 CloudFormation 写成的解决方案。该解决方案包括了一个新的 CloudFront 分发。我的挑战是,我想将一个自定义域名mysite.example.com添加到dxxxxxx.cloudfront.net分发中。我已经使用了别名,并且用 Certificate Manager 创建了证书。我的问题是如何将新域名添加到现有的 CloudFront 中。
mysite.example.com
dxxxxxx.cloudfront.net
据我所知,我可以使用 Distribution.fromDistributionAttributes 来导入现有的分发。
例如:
const distribution = cloudfront.Distribution.fromDistributionAttributes(this, 'ImportedDist', { domainName: 'd111111abcdef8.cloudfront.net', distributionId: '012345ABCDEF', });
如果我已经准备好了别名和证书 ARN,例如:
const domainName = 'mysite.example.com'; const certificateArn = 'arn:aws:acm:us-east-1: 123456789012:certificate/abcdefgh-1234-5678-9012-abcdefghujkl';
接下来该如何操作?
【以下的回答经过翻译处理】 使用 CDK 无法(轻松)将其添加进来。因为您是从属性中查找的,当合成模板时,模板的资源部分中不会有 CloudFront 分发。
您需要使用 CDK 创建一个包含分发的堆栈。为该堆栈合成模板。然后使用该模板手动创建堆栈,并将 CloudFront 的分发导入堆栈。
这样,您就可以通过 CDK 与分发进行交互。
更简单的方法是使用自 定义资源,使用 Update Distribution API 添加这些值。
您未登录。 登录 发布回答。
一个好的回答可以清楚地解答问题和提供建设性反馈,并能促进提问者的职业发展。