【发布时间】:2022-04-20 21:01:36
【问题描述】:
作为我在 CDK 中的 CodePipeline 的一部分,作为最后一步,我希望使 Cloudfront 缓存无效。
这是我当前的部署操作步骤:
{
stageName: 'Deploy',
actions: [
new codepipelineActions.S3DeployAction({
actionName: 'S3Deploy',
bucket: frontendCodeBucket, // See bucket config below
input: buildOutput, // Output from Build step
}),
]
}
这是我的代码桶和 CF 分布:
const frontendCodeBucket = new s3.Bucket(this, 'FrontendBucketStaging', {
websiteIndexDocument: 'index.html',
encryption: s3.BucketEncryption.S3_MANAGED,
blockPublicAccess: s3.BlockPublicAccess.BLOCK_ALL,
bucketName: 'something',
removalPolicy: RemovalPolicy.DESTROY,
});
const distribution = new cloudfront.CloudFrontWebDistribution(this, 'FrontendCloudfrontStaging', {
originConfigs: [
{
s3OriginSource: {
s3BucketSource: frontendCodeBucket,
originAccessIdentity: oai,
},
behaviors : [ {isDefaultBehavior: true}]
}
],
我找不到通过 S3DeployAction 使缓存失效的任何方法。 在使用静态网站和 Cloudfront 时,这似乎是最常见的事情之一。这根本不可能吗?
如果不是。有解决方法吗? 例如,在非管道流程中,这样的事情应该可以工作(我读过):
new s3deploy.BucketDeployment(this, 'DeployWithInvalidation', {
sources: [<some assets>],
destinationBucket: bucket,
distribution,
distributionPaths: ['/*'],
});
那么有没有办法在管道中添加这样一个步骤,而不是“Action”?
非常高兴获得任何帮助或指点。我对 CDK 很陌生,但这感觉就像有人想做的一件很常见的事情,所以我希望我只是在这里遗漏了一些东西。除了最后一步之外,管道运行良好。
【问题讨论】:
标签: amazon-web-services amazon-cloudformation amazon-cloudfront aws-cdk