-
Notifications
You must be signed in to change notification settings - Fork 4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(cfnspec): v101.0.0 introduced specific types on several types tha…
…t previously were typed as json (#23448) This PR reverts all changes where a type changed from `Json` to a specific type in CfnSpec v101.0.0. See 3951f09 - [x] 000_AWS_Backup.json - [x] 000_AWS_CloudFormation.json - [x] 000_AWS_CodeGuruProfiler.json - [x] 000_AWS_Config.json - [x] 000_AWS_Connect.json - [x] 000_AWS_DataBrew.json - [x] 000_AWS_EC2.json - [x] 000_AWS_ECR.json - [x] 000_AWS_ElastiCache.json - [x] 000_AWS_FIS.json - [x] 000_AWS_Forecast.json - [x] 000_AWS_GreengrassV2.json - [x] 000_AWS_IoT.json - [ ] ~000_AWS_IoTAnalytics.json~ - [x] 000_AWS_IoTCoreDeviceAdvisor.json - [ ] ~000_AWS_IoTFleetWise.json~ - [x] 000_AWS_IoTSiteWise.json - [x] 000_AWS_IoTTwinMaker.json - [x] 000_AWS_IoTWireless.json - [ ] ~000_AWS_LakeFormation.json~ - [x] 000_AWS_Lex.json - [x] 000_AWS_LookoutEquipment.json - [ ] ~000_AWS_Macie.json~ - [x] 000_AWS_MemoryDB.json - [x] 000_AWS_Personalize.json - [x] 000_AWS_Redshift.json - [x] 000_AWS_Route53.json - [x] 000_AWS_S3.json - [x] 000_AWS_S3ObjectLambda.json - [x] 000_AWS_S3Outposts.json - [x] 000_AWS_SageMaker.json - [ ] ~000_AWS_Scheduler.json~ - [ ] ~000_AWS_StepFunctions.json~ - [ ] ~000_AWS_Timestream.json~ - [x] 000_AWS_Transfer.json - [x] 000_AWS_WAFv2.json ---- ### All Submissions: * [x] Have you followed the guidelines in our [Contributing guide?](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md) ### Adding new Construct Runtime Dependencies: * [ ] This PR adds new construct runtime dependencies following the process described [here](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md/#adding-construct-runtime-dependencies) ### New Features * [ ] Have you added the new feature to an [integration test](https://github.com/aws/aws-cdk/blob/main/INTEGRATION_TESTS.md)? * [ ] Did you use `yarn integ` to deploy the infrastructure and generate the snapshot (i.e. `yarn integ` without `--dry-run`)? *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
- Loading branch information
1 parent
e49e57d
commit 4fbc182
Showing
19 changed files
with
1,261 additions
and
476 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 5 additions & 5 deletions
10
.../test/integ.vpc-flow-logs.js.snapshot/FlowLogsDefaultTestDeployAssert6AFD1854.assets.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
...ges/@aws-cdk/aws-ec2/test/integ.vpc-flow-logs.js.snapshot/FlowLogsFeatureFlag.assets.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 5 additions & 5 deletions
10
packages/@aws-cdk/aws-ec2/test/integ.vpc-flow-logs.js.snapshot/FlowLogsTestStack.assets.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
144 changes: 0 additions & 144 deletions
144
.../asset.33e2651435a0d472a75c1e033c9832b21321d9e56711926b04c5705e5f63874c/__entrypoint__.js
This file was deleted.
Oops, something went wrong.
118 changes: 118 additions & 0 deletions
118
.../asset.60767da3831353fede3cfe92efef10580a600592dec8ccbb06c051e95b9c1b26/__entrypoint__.js
Large diffs are not rendered by default.
Oops, something went wrong.
1 change: 1 addition & 0 deletions
1
...napshot/asset.60767da3831353fede3cfe92efef10580a600592dec8ccbb06c051e95b9c1b26/index.d.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export declare function handler(event: AWSLambda.CloudFormationCustomResourceEvent): Promise<void>; |
File renamed without changes.
82 changes: 82 additions & 0 deletions
82
....snapshot/asset.60767da3831353fede3cfe92efef10580a600592dec8ccbb06c051e95b9c1b26/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
// eslint-disable-next-line import/no-extraneous-dependencies | ||
import { S3 } from 'aws-sdk'; | ||
|
||
const AUTO_DELETE_OBJECTS_TAG = 'aws-cdk:auto-delete-objects'; | ||
|
||
const s3 = new S3(); | ||
|
||
export async function handler(event: AWSLambda.CloudFormationCustomResourceEvent) { | ||
switch (event.RequestType) { | ||
case 'Create': | ||
return; | ||
case 'Update': | ||
return onUpdate(event); | ||
case 'Delete': | ||
return onDelete(event.ResourceProperties?.BucketName); | ||
} | ||
} | ||
|
||
async function onUpdate(event: AWSLambda.CloudFormationCustomResourceEvent) { | ||
const updateEvent = event as AWSLambda.CloudFormationCustomResourceUpdateEvent; | ||
const oldBucketName = updateEvent.OldResourceProperties?.BucketName; | ||
const newBucketName = updateEvent.ResourceProperties?.BucketName; | ||
const bucketNameHasChanged = newBucketName != null && oldBucketName != null && newBucketName !== oldBucketName; | ||
|
||
/* If the name of the bucket has changed, CloudFormation will try to delete the bucket | ||
and create a new one with the new name. So we have to delete the contents of the | ||
bucket so that this operation does not fail. */ | ||
if (bucketNameHasChanged) { | ||
return onDelete(oldBucketName); | ||
} | ||
} | ||
|
||
/** | ||
* Recursively delete all items in the bucket | ||
* | ||
* @param bucketName the bucket name | ||
*/ | ||
async function emptyBucket(bucketName: string) { | ||
const listedObjects = await s3.listObjectVersions({ Bucket: bucketName }).promise(); | ||
const contents = [...listedObjects.Versions ?? [], ...listedObjects.DeleteMarkers ?? []]; | ||
if (contents.length === 0) { | ||
return; | ||
} | ||
|
||
const records = contents.map((record: any) => ({ Key: record.Key, VersionId: record.VersionId })); | ||
await s3.deleteObjects({ Bucket: bucketName, Delete: { Objects: records } }).promise(); | ||
|
||
if (listedObjects?.IsTruncated) { | ||
await emptyBucket(bucketName); | ||
} | ||
} | ||
|
||
async function onDelete(bucketName?: string) { | ||
if (!bucketName) { | ||
throw new Error('No BucketName was provided.'); | ||
} | ||
if (!await isBucketTaggedForDeletion(bucketName)) { | ||
process.stdout.write(`Bucket does not have '${AUTO_DELETE_OBJECTS_TAG}' tag, skipping cleaning.\n`); | ||
return; | ||
} | ||
try { | ||
await emptyBucket(bucketName); | ||
} catch (e) { | ||
if (e.code !== 'NoSuchBucket') { | ||
throw e; | ||
} | ||
// Bucket doesn't exist. Ignoring | ||
} | ||
} | ||
|
||
/** | ||
* The bucket will only be tagged for deletion if it's being deleted in the same | ||
* deployment as this Custom Resource. | ||
* | ||
* If the Custom Resource is every deleted before the bucket, it must be because | ||
* `autoDeleteObjects` has been switched to false, in which case the tag would have | ||
* been removed before we get to this Delete event. | ||
*/ | ||
async function isBucketTaggedForDeletion(bucketName: string) { | ||
const response = await s3.getBucketTagging({ Bucket: bucketName }).promise(); | ||
return response.TagSet.some(tag => tag.Key === AUTO_DELETE_OBJECTS_TAG && tag.Value === 'true'); | ||
} |
Oops, something went wrong.