Skip to content

Commit

Permalink
fix(s3): auto-delete-objects fails when bucket doesn't exist (#26433)
Browse files Browse the repository at this point in the history
The AutoDeleteObjects Custom Resource should pass when the bucket doesn't exist.

With #16756 we introduced a safety check to only delete buckets that are marked for object-deletion.
This check would unintentionally bypass the special case to mark the CR deletion as successful when the bucket doesn't exist.
Additionally, with the upgrade to SDK v3 we need to change the check from `error.code` to check for the actual error instance.

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
  • Loading branch information
mrgrain committed Jul 19, 2023
1 parent 47f15a6 commit 228901a
Show file tree
Hide file tree
Showing 176 changed files with 10,289 additions and 4,987 deletions.
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
{
"version": "32.0.0",
"files": {
"89c643a8a6c919d906e0b1cb079b0c5e131cf3cc19c05126f90fc118647fb08c": {
"216218e507a977a1bb3592f29c1a62ab3e0a9eb25569109a395315638e154329": {
"source": {
"path": "asset.89c643a8a6c919d906e0b1cb079b0c5e131cf3cc19c05126f90fc118647fb08c",
"path": "asset.216218e507a977a1bb3592f29c1a62ab3e0a9eb25569109a395315638e154329",
"packaging": "zip"
},
"destinations": {
"current_account-current_region": {
"bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}",
"objectKey": "89c643a8a6c919d906e0b1cb079b0c5e131cf3cc19c05126f90fc118647fb08c.zip",
"objectKey": "216218e507a977a1bb3592f29c1a62ab3e0a9eb25569109a395315638e154329.zip",
"assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}"
}
}
Expand All @@ -27,15 +27,15 @@
}
}
},
"03976f19a1ccfcbacb9ef3d50473b535965747dcfb46bad6966e5da8ccc9b35b": {
"05ade89a272158845b639cd0b4928c2443b24c71c37e71c0b82096c1dfe322a2": {
"source": {
"path": "StackSetPipelineStack.template.json",
"packaging": "file"
},
"destinations": {
"current_account-current_region": {
"bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}",
"objectKey": "03976f19a1ccfcbacb9ef3d50473b535965747dcfb46bad6966e5da8ccc9b35b.json",
"objectKey": "05ade89a272158845b639cd0b4928c2443b24c71c37e71c0b82096c1dfe322a2.json",
"assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}"
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@
"S3Bucket": {
"Fn::Sub": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}"
},
"S3Key": "89c643a8a6c919d906e0b1cb079b0c5e131cf3cc19c05126f90fc118647fb08c.zip"
"S3Key": "216218e507a977a1bb3592f29c1a62ab3e0a9eb25569109a395315638e154329.zip"
},
"Timeout": 900,
"MemorySize": 128,
Expand Down Expand Up @@ -238,6 +238,12 @@
"PipelineC660917D": {
"Type": "AWS::CodePipeline::Pipeline",
"Properties": {
"ArtifactStore": {
"Location": {
"Ref": "ArtifactBucket7410C9EF"
},
"Type": "S3"
},
"RoleArn": {
"Fn::GetAtt": [
"PipelineRoleD68726F7",
Expand Down Expand Up @@ -337,13 +343,7 @@
],
"Name": "Cfn"
}
],
"ArtifactStore": {
"Location": {
"Ref": "ArtifactBucket7410C9EF"
},
"Type": "S3"
}
]
},
"DependsOn": [
"PipelineRoleDefaultPolicyC7A05455",
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"validateOnSynth": false,
"assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-deploy-role-${AWS::AccountId}-${AWS::Region}",
"cloudFormationExecutionRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-cfn-exec-role-${AWS::AccountId}-${AWS::Region}",
"stackTemplateAssetObjectUrl": "s3://cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}/03976f19a1ccfcbacb9ef3d50473b535965747dcfb46bad6966e5da8ccc9b35b.json",
"stackTemplateAssetObjectUrl": "s3://cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}/05ade89a272158845b639cd0b4928c2443b24c71c37e71c0b82096c1dfe322a2.json",
"requiresBootstrapStackVersion": 6,
"bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version",
"additionalDependencies": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,12 @@
"attributes": {
"aws:cdk:cloudformation:type": "AWS::CodePipeline::Pipeline",
"aws:cdk:cloudformation:props": {
"artifactStore": {
"type": "S3",
"location": {
"Ref": "ArtifactBucket7410C9EF"
}
},
"roleArn": {
"Fn::GetAtt": [
"PipelineRoleD68726F7",
Expand Down Expand Up @@ -405,13 +411,7 @@
}
]
}
],
"artifactStore": {
"type": "S3",
"location": {
"Ref": "ArtifactBucket7410C9EF"
}
}
]
}
},
"constructInfo": {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
{
"version": "32.0.0",
"files": {
"89c643a8a6c919d906e0b1cb079b0c5e131cf3cc19c05126f90fc118647fb08c": {
"216218e507a977a1bb3592f29c1a62ab3e0a9eb25569109a395315638e154329": {
"source": {
"path": "asset.89c643a8a6c919d906e0b1cb079b0c5e131cf3cc19c05126f90fc118647fb08c",
"path": "asset.216218e507a977a1bb3592f29c1a62ab3e0a9eb25569109a395315638e154329",
"packaging": "zip"
},
"destinations": {
"current_account-current_region": {
"bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}",
"objectKey": "89c643a8a6c919d906e0b1cb079b0c5e131cf3cc19c05126f90fc118647fb08c.zip",
"objectKey": "216218e507a977a1bb3592f29c1a62ab3e0a9eb25569109a395315638e154329.zip",
"assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}"
}
}
Expand Down Expand Up @@ -53,15 +53,15 @@
}
}
},
"ae905796f14ca862d4e6f19382d8b2aae475b34b7c2395bd8fea7789d31809c6": {
"c7f8ee5d9578c611b742c0b6a8bd6f94191be5d73984891ef4dbecc336be1be3": {
"source": {
"path": "aws-cdk-codepipeline-elastic-beanstalk-deploy.template.json",
"packaging": "file"
},
"destinations": {
"current_account-current_region": {
"bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}",
"objectKey": "ae905796f14ca862d4e6f19382d8b2aae475b34b7c2395bd8fea7789d31809c6.json",
"objectKey": "c7f8ee5d9578c611b742c0b6a8bd6f94191be5d73984891ef4dbecc336be1be3.json",
"assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}"
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@
"S3Bucket": {
"Fn::Sub": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}"
},
"S3Key": "89c643a8a6c919d906e0b1cb079b0c5e131cf3cc19c05126f90fc118647fb08c.zip"
"S3Key": "216218e507a977a1bb3592f29c1a62ab3e0a9eb25569109a395315638e154329.zip"
},
"Timeout": 900,
"MemorySize": 128,
Expand Down Expand Up @@ -320,12 +320,6 @@
},
"S3Key": "9eb41a5505d37607ac419321497a4f8c21cf0ee1f9b4a6b29aa04301aea5c7fd.zip"
},
"Role": {
"Fn::GetAtt": [
"CustomCDKBucketDeployment8693BB64968944B69AAFB0CC9EB8756CServiceRole89A01265",
"Arn"
]
},
"Environment": {
"Variables": {
"AWS_CA_BUNDLE": "/etc/pki/ca-trust/extracted/pem/tls-ca-bundle.pem"
Expand All @@ -337,6 +331,12 @@
"Ref": "DeployAppAwsCliLayerAEF99B2F"
}
],
"Role": {
"Fn::GetAtt": [
"CustomCDKBucketDeployment8693BB64968944B69AAFB0CC9EB8756CServiceRole89A01265",
"Arn"
]
},
"Runtime": "python3.9",
"Timeout": 900
},
Expand Down Expand Up @@ -393,14 +393,14 @@
"instanceprofile": {
"Type": "AWS::IAM::InstanceProfile",
"Properties": {
"InstanceProfileName": {
"Ref": "instanceprofilerole786BCBC7"
},
"Roles": [
{
"Ref": "instanceprofilerole786BCBC7"
}
],
"InstanceProfileName": {
"Ref": "instanceprofilerole786BCBC7"
}
]
}
},
"beastalkapp": {
Expand Down Expand Up @@ -538,6 +538,12 @@
"PipelineC660917D": {
"Type": "AWS::CodePipeline::Pipeline",
"Properties": {
"ArtifactStore": {
"Location": {
"Ref": "PipelineBucketB967BD35"
},
"Type": "S3"
},
"RoleArn": {
"Fn::GetAtt": [
"PipelineRoleD68726F7",
Expand Down Expand Up @@ -617,13 +623,7 @@
],
"Name": "Deploy"
}
],
"ArtifactStore": {
"Location": {
"Ref": "PipelineBucketB967BD35"
},
"Type": "S3"
}
]
},
"DependsOn": [
"PipelineRoleDefaultPolicyC7A05455",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"validateOnSynth": false,
"assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-deploy-role-${AWS::AccountId}-${AWS::Region}",
"cloudFormationExecutionRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-cfn-exec-role-${AWS::AccountId}-${AWS::Region}",
"stackTemplateAssetObjectUrl": "s3://cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}/ae905796f14ca862d4e6f19382d8b2aae475b34b7c2395bd8fea7789d31809c6.json",
"stackTemplateAssetObjectUrl": "s3://cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}/c7f8ee5d9578c611b742c0b6a8bd6f94191be5d73984891ef4dbecc336be1be3.json",
"requiresBootstrapStackVersion": 6,
"bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version",
"additionalDependencies": [
Expand Down Expand Up @@ -66,10 +66,7 @@
"/aws-cdk-codepipeline-elastic-beanstalk-deploy/DeployApp/AwsCliLayer/Resource": [
{
"type": "aws:cdk:logicalId",
"data": "DeployAppAwsCliLayerAEF99B2F",
"trace": [
"!!DESTRUCTIVE_CHANGES: WILL_REPLACE"
]
"data": "DeployAppAwsCliLayerAEF99B2F"
}
],
"/aws-cdk-codepipeline-elastic-beanstalk-deploy/DeployApp/CustomResource/Default": [
Expand Down Expand Up @@ -123,10 +120,7 @@
"/aws-cdk-codepipeline-elastic-beanstalk-deploy/beanstlk-env": [
{
"type": "aws:cdk:logicalId",
"data": "beanstlkenv",
"trace": [
"!!DESTRUCTIVE_CHANGES: WILL_REPLACE"
]
"data": "beanstlkenv"
}
],
"/aws-cdk-codepipeline-elastic-beanstalk-deploy/Pipeline/Role/Resource": [
Expand Down

0 comments on commit 228901a

Please sign in to comment.