Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(cfnspec): v101.0.0 introduced specific types on several types that previously were typed as json #23448

Merged
merged 33 commits into from Dec 23, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
b892f6d
AWS Backup
madeline-k Dec 22, 2022
a8e4047
CloudFormation
madeline-k Dec 22, 2022
450d032
CodeGuruProfiler
madeline-k Dec 22, 2022
11dc1f3
Config
madeline-k Dec 22, 2022
69bd208
Connect
madeline-k Dec 22, 2022
8d768be
DataBrew
madeline-k Dec 22, 2022
9a540bf
EC2
madeline-k Dec 22, 2022
6c71fd5
ECR
madeline-k Dec 22, 2022
f5d1a2c
ElastiCache
madeline-k Dec 22, 2022
b64eb7d
FIS
madeline-k Dec 23, 2022
dbf875e
Forecast
madeline-k Dec 23, 2022
67cec5f
GreengrassV2
madeline-k Dec 23, 2022
0dc64af
IoT
madeline-k Dec 23, 2022
3aa0133
IoTCoreDeviceAdvisor
madeline-k Dec 23, 2022
f2265bc
IoTSiteWise
madeline-k Dec 23, 2022
388b757
IoTTwinMaker
madeline-k Dec 23, 2022
1562d94
IoTWireless
madeline-k Dec 23, 2022
6660ec6
Lex
madeline-k Dec 23, 2022
5e56e16
LookoutEquipment
madeline-k Dec 23, 2022
f5f58bc
MemoryDB
madeline-k Dec 23, 2022
19243e9
Personalize
madeline-k Dec 23, 2022
1a2c615
Redshift
madeline-k Dec 23, 2022
e17b669
Route53
madeline-k Dec 23, 2022
d0ff7bc
S3
madeline-k Dec 23, 2022
98cffce
S3ObjectLambda
madeline-k Dec 23, 2022
6c29414
S3Outposts
madeline-k Dec 23, 2022
9112024
SageMaker
madeline-k Dec 23, 2022
e219c80
Transfer
madeline-k Dec 23, 2022
076a20c
WAFv2
madeline-k Dec 23, 2022
25a3d7f
fix copy-paste error in IoTTwinMaker
madeline-k Dec 23, 2022
f5326f8
Revert "chore: fixes for upcoming cfnspec"
madeline-k Dec 23, 2022
8f817d8
add back change to comment out resource-attribute awslint rule
madeline-k Dec 23, 2022
bcb26d5
Merge branch 'main' into madeline-k/fix-cfn-spec-primitive-type-json
mergify[bot] Dec 23, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 1 addition & 11 deletions packages/@aws-cdk/aws-ec2/lib/vpc-flow-logs.ts
Expand Up @@ -676,7 +676,7 @@ export class FlowLog extends FlowLogBase {
}

const flowLog = new CfnFlowLog(this, 'FlowLog', {
destinationOptions: renderDestinationOptions(destinationConfig.destinationOptions),
destinationOptions: destinationConfig.destinationOptions,
deliverLogsPermissionArn: this.iamRole ? this.iamRole.roleArn : undefined,
logDestinationType: destinationConfig.logDestinationType,
logGroupName: this.logGroup ? this.logGroup.logGroupName : undefined,
Expand All @@ -694,13 +694,3 @@ export class FlowLog extends FlowLogBase {
this.node.defaultChild = flowLog;
}
}

function renderDestinationOptions(opts: DestinationOptions | undefined): CfnFlowLog.DestinationOptionsProperty | undefined {
if (opts === undefined) { return undefined; }

return {
fileFormat: opts.fileFormat ?? 'plain-text',
hiveCompatiblePartitions: opts.hiveCompatiblePartitions ?? false,
perHourPartition: opts.perHourPartition ?? false,
};
}
@@ -1,28 +1,28 @@
{
"version": "21.0.0",
"files": {
"3074b79e05e7b98930b6449e01baa3e68b32ecff86328933c2542f7b7fe6fdac": {
"b54b99043c35bd080b9d9d1afce31e3541cf15b679799ba980ed40c837dcb03b": {
"source": {
"path": "asset.3074b79e05e7b98930b6449e01baa3e68b32ecff86328933c2542f7b7fe6fdac.bundle",
"path": "asset.b54b99043c35bd080b9d9d1afce31e3541cf15b679799ba980ed40c837dcb03b.bundle",
"packaging": "zip"
},
"destinations": {
"current_account-current_region": {
"bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}",
"objectKey": "3074b79e05e7b98930b6449e01baa3e68b32ecff86328933c2542f7b7fe6fdac.zip",
"objectKey": "b54b99043c35bd080b9d9d1afce31e3541cf15b679799ba980ed40c837dcb03b.zip",
"assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}"
}
}
},
"dd951509b1e22484b40a66a661cb8cebce3087b8cb381e3dcf02e641e5eb08cd": {
"1dcf759cd2c8928f5b1acfbf439f1751e25367a5ac61ba5e640ff8b78fdf89f7": {
"source": {
"path": "FlowLogsDefaultTestDeployAssert6AFD1854.template.json",
"packaging": "file"
},
"destinations": {
"current_account-current_region": {
"bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}",
"objectKey": "dd951509b1e22484b40a66a661cb8cebce3087b8cb381e3dcf02e641e5eb08cd.json",
"objectKey": "1dcf759cd2c8928f5b1acfbf439f1751e25367a5ac61ba5e640ff8b78fdf89f7.json",
"assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}"
}
}
Expand Down
Expand Up @@ -31,7 +31,7 @@
}
},
"flattenResponse": "false",
"salt": "1668693953813"
"salt": "1666810703150"
},
"UpdateReplacePolicy": "Delete",
"DeletionPolicy": "Delete"
Expand Down Expand Up @@ -115,7 +115,7 @@
"S3Bucket": {
"Fn::Sub": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}"
},
"S3Key": "3074b79e05e7b98930b6449e01baa3e68b32ecff86328933c2542f7b7fe6fdac.zip"
"S3Key": "b54b99043c35bd080b9d9d1afce31e3541cf15b679799ba980ed40c837dcb03b.zip"
},
"Timeout": 120,
"Handler": "index.handler",
Expand Down
@@ -1,15 +1,15 @@
{
"version": "21.0.0",
"files": {
"8f4f8db3ea3ad2d5f5678275c75dce7d9b67b46d8df7d92c62913bdc5a03cd3f": {
"2db53e096625b4b167fb15dd7bdc246692b381f45e28c509614fef7d41c20bc9": {
"source": {
"path": "FlowLogsFeatureFlag.template.json",
"packaging": "file"
},
"destinations": {
"current_account-current_region": {
"bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}",
"objectKey": "8f4f8db3ea3ad2d5f5678275c75dce7d9b67b46d8df7d92c62913bdc5a03cd3f.json",
"objectKey": "2db53e096625b4b167fb15dd7bdc246692b381f45e28c509614fef7d41c20bc9.json",
"assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}"
}
}
Expand Down
Expand Up @@ -524,6 +524,7 @@
"Ref": "VPCB9E5F0B4"
},
"ResourceType": "VPC",
"TrafficType": "ALL",
"LogDestination": {
"Fn::GetAtt": [
"VPCFlowLogsS3BucketFB7DC2BE",
Expand All @@ -536,8 +537,7 @@
"Key": "Name",
"Value": "FlowLogsFeatureFlag/VPC"
}
],
"TrafficType": "ALL"
]
}
},
"VPCFlowLogsS3WithDestinationOptionsBucket1B7AC456": {
Expand Down Expand Up @@ -673,10 +673,11 @@
"Ref": "VPCB9E5F0B4"
},
"ResourceType": "VPC",
"TrafficType": "ALL",
"DestinationOptions": {
"FileFormat": "plain-text",
"HiveCompatiblePartitions": true,
"PerHourPartition": false
"fileFormat": "plain-text",
"perHourPartition": false,
"hiveCompatiblePartitions": true
},
"LogDestination": {
"Fn::GetAtt": [
Expand All @@ -690,8 +691,7 @@
"Key": "Name",
"Value": "FlowLogsFeatureFlag/VPC"
}
],
"TrafficType": "ALL"
]
}
},
"FlowLogsInstanceInstanceSecurityGroupF61782E0": {
Expand Down
@@ -1,28 +1,28 @@
{
"version": "21.0.0",
"files": {
"33e2651435a0d472a75c1e033c9832b21321d9e56711926b04c5705e5f63874c": {
"bb426cfb5fed5237e5928f871893b243ddf86a591a592b558bd29f60e28bad9d": {
"source": {
"path": "asset.33e2651435a0d472a75c1e033c9832b21321d9e56711926b04c5705e5f63874c",
"path": "asset.bb426cfb5fed5237e5928f871893b243ddf86a591a592b558bd29f60e28bad9d",
"packaging": "zip"
},
"destinations": {
"current_account-current_region": {
"bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}",
"objectKey": "33e2651435a0d472a75c1e033c9832b21321d9e56711926b04c5705e5f63874c.zip",
"objectKey": "bb426cfb5fed5237e5928f871893b243ddf86a591a592b558bd29f60e28bad9d.zip",
"assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}"
}
}
},
"23955aa16c5d59106d93ecce9cedd43aa5782fbf23bb2ef8549b2119345a6f79": {
"2090a74d484bc155b48d7511b99e4921b8f55e488c3fe1500cffede0cdfd33b7": {
"source": {
"path": "FlowLogsTestStack.template.json",
"packaging": "file"
},
"destinations": {
"current_account-current_region": {
"bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}",
"objectKey": "23955aa16c5d59106d93ecce9cedd43aa5782fbf23bb2ef8549b2119345a6f79.json",
"objectKey": "2090a74d484bc155b48d7511b99e4921b8f55e488c3fe1500cffede0cdfd33b7.json",
"assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}"
}
}
Expand Down
Expand Up @@ -524,6 +524,7 @@
"Ref": "VPCB9E5F0B4"
},
"ResourceType": "VPC",
"TrafficType": "ALL",
"LogDestination": {
"Fn::GetAtt": [
"VPCFlowLogsS3BucketFB7DC2BE",
Expand All @@ -536,8 +537,7 @@
"Key": "Name",
"Value": "FlowLogsTestStack/VPC"
}
],
"TrafficType": "ALL"
]
}
},
"VPCFlowLogsS3KeyPrefixFlowLogB57F1746": {
Expand All @@ -547,6 +547,7 @@
"Ref": "VPCB9E5F0B4"
},
"ResourceType": "VPC",
"TrafficType": "ALL",
"LogDestination": {
"Fn::Join": [
"",
Expand All @@ -567,8 +568,7 @@
"Key": "Name",
"Value": "FlowLogsTestStack/VPC"
}
],
"TrafficType": "ALL"
]
}
},
"FlowLogsCWIAMRole017AD736": {
Expand Down Expand Up @@ -643,6 +643,7 @@
"Ref": "VPCB9E5F0B4"
},
"ResourceType": "VPC",
"TrafficType": "ALL",
"DeliverLogsPermissionArn": {
"Fn::GetAtt": [
"FlowLogsCWIAMRole017AD736",
Expand All @@ -652,8 +653,7 @@
"LogDestinationType": "cloud-watch-logs",
"LogGroupName": {
"Ref": "FlowLogsCWLogGroup0398E8F8"
},
"TrafficType": "ALL"
}
}
},
"Bucket83908E77": {
Expand Down Expand Up @@ -888,7 +888,7 @@
"S3Bucket": {
"Fn::Sub": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}"
},
"S3Key": "33e2651435a0d472a75c1e033c9832b21321d9e56711926b04c5705e5f63874c.zip"
"S3Key": "bb426cfb5fed5237e5928f871893b243ddf86a591a592b558bd29f60e28bad9d.zip"
},
"Timeout": 900,
"MemorySize": 128,
Expand Down

This file was deleted.

Large diffs are not rendered by default.

@@ -0,0 +1 @@
export declare function handler(event: AWSLambda.CloudFormationCustomResourceEvent): Promise<void>;
@@ -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');
}