Depend on bucket and policy before configuring ELB logging #1633
Description
I tried adding logging support to my VPC using the following:
const alb = new Alb.ApplicationLoadBalancer(this, 'LB', {
vpc,
internetFacing: true
})
const bucket = new Bucket(this, 'Bucket', {
encryption: BucketEncryption.KmsManaged
})
alb.logAccessLogs(bucket)
When running cdk deploy
I got an expected warning about IAM changes and the permission looks to be correct.
+ │ ${Bucket.Arn}/* │ Allow │ s3:PutObject │ AWS:arn:${AWS::Partition}:iam::127311923021:root
It appears that there is a bug in the CF template which is not waiting on the bucket policy to finish completion before it attempts to add the logging in the VPC.
Access Denied for bucket: [BUCKET NAME]. Please check S3bucket permission (Service: AmazonElasticLoadBalancingV2; Status Code: 400; Error Code: InvalidConfigurationRequest; Request ID: 657ff61c-23dd-11e9-94e9-c57251c19c33)
I confirmed this was the case by checking the CF events in the console.