Skip to content

Commit 4b6dc8c

Browse files
authored
feat(servicecatalog): ProductStack memoryLimit prop (#30105)
### Issue # (if applicable) Closes #29862 ### Reason for this change Exposes `BucketDeployment`'s `memoryLimit` prop in the `ProductStack` class. While not an ideal solution, this allows users to handle larger files ### Description of changes * Added `memoryLimit` to `ProductStackProps` and the internal `ProductStackSynthesizerProps` ### Description of how you validated changes Updated unit and integ tests ### Checklist - [x] My code adheres to the [CONTRIBUTING GUIDE](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md) and [DESIGN GUIDELINES](https://github.com/aws/aws-cdk/blob/main/docs/DESIGN_GUIDELINES.md) ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
1 parent a53517c commit 4b6dc8c

File tree

8 files changed

+136
-42
lines changed

8 files changed

+136
-42
lines changed

packages/@aws-cdk-testing/framework-integ/test/aws-servicecatalog/test/integ.two-products.js.snapshot/integ-servicecatalog-two-products.assets.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/@aws-cdk-testing/framework-integ/test/aws-servicecatalog/test/integ.two-products.js.snapshot/integ-servicecatalog-two-products.template.json

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
"Value": "true"
4242
},
4343
{
44-
"Key": "aws-cdk:cr-owned:8a3b3620",
44+
"Key": "aws-cdk:cr-owned:978d2e9b",
4545
"Value": "true"
4646
}
4747
]
@@ -130,12 +130,12 @@
130130
"Description": "/opt/awscli/aws"
131131
}
132132
},
133-
"TestAssetBucketProductAssetsDeploymentCustomResource5F81E30F": {
133+
"TestAssetBucketProductAssetsDeploymentCustomResource256MiBB5A849A6": {
134134
"Type": "Custom::CDKBucketDeployment",
135135
"Properties": {
136136
"ServiceToken": {
137137
"Fn::GetAtt": [
138-
"CustomCDKBucketDeployment8693BB64968944B69AAFB0CC9EB8756C81C01536",
138+
"CustomCDKBucketDeployment8693BB64968944B69AAFB0CC9EB8756C256MiB5F7BD223",
139139
"Arn"
140140
]
141141
},
@@ -217,7 +217,7 @@
217217
"CustomS3AutoDeleteObjectsCustomResourceProviderRole3B1BD092"
218218
]
219219
},
220-
"CustomCDKBucketDeployment8693BB64968944B69AAFB0CC9EB8756CServiceRole89A01265": {
220+
"CustomCDKBucketDeployment8693BB64968944B69AAFB0CC9EB8756C256MiBServiceRoleF991ED9F": {
221221
"Type": "AWS::IAM::Role",
222222
"Properties": {
223223
"AssumeRolePolicyDocument": {
@@ -248,7 +248,7 @@
248248
]
249249
}
250250
},
251-
"CustomCDKBucketDeployment8693BB64968944B69AAFB0CC9EB8756CServiceRoleDefaultPolicy88902FDF": {
251+
"CustomCDKBucketDeployment8693BB64968944B69AAFB0CC9EB8756C256MiBServiceRoleDefaultPolicyE5468F0E": {
252252
"Type": "AWS::IAM::Policy",
253253
"Properties": {
254254
"PolicyDocument": {
@@ -327,15 +327,15 @@
327327
],
328328
"Version": "2012-10-17"
329329
},
330-
"PolicyName": "CustomCDKBucketDeployment8693BB64968944B69AAFB0CC9EB8756CServiceRoleDefaultPolicy88902FDF",
330+
"PolicyName": "CustomCDKBucketDeployment8693BB64968944B69AAFB0CC9EB8756C256MiBServiceRoleDefaultPolicyE5468F0E",
331331
"Roles": [
332332
{
333-
"Ref": "CustomCDKBucketDeployment8693BB64968944B69AAFB0CC9EB8756CServiceRole89A01265"
333+
"Ref": "CustomCDKBucketDeployment8693BB64968944B69AAFB0CC9EB8756C256MiBServiceRoleF991ED9F"
334334
}
335335
]
336336
}
337337
},
338-
"CustomCDKBucketDeployment8693BB64968944B69AAFB0CC9EB8756C81C01536": {
338+
"CustomCDKBucketDeployment8693BB64968944B69AAFB0CC9EB8756C256MiB5F7BD223": {
339339
"Type": "AWS::Lambda::Function",
340340
"Properties": {
341341
"Code": {
@@ -353,18 +353,19 @@
353353
"Ref": "TestAssetBucketProductAssetsDeploymentAwsCliLayerD1E52C82"
354354
}
355355
],
356+
"MemorySize": 256,
356357
"Role": {
357358
"Fn::GetAtt": [
358-
"CustomCDKBucketDeployment8693BB64968944B69AAFB0CC9EB8756CServiceRole89A01265",
359+
"CustomCDKBucketDeployment8693BB64968944B69AAFB0CC9EB8756C256MiBServiceRoleF991ED9F",
359360
"Arn"
360361
]
361362
},
362363
"Runtime": "python3.9",
363364
"Timeout": 900
364365
},
365366
"DependsOn": [
366-
"CustomCDKBucketDeployment8693BB64968944B69AAFB0CC9EB8756CServiceRoleDefaultPolicy88902FDF",
367-
"CustomCDKBucketDeployment8693BB64968944B69AAFB0CC9EB8756CServiceRole89A01265"
367+
"CustomCDKBucketDeployment8693BB64968944B69AAFB0CC9EB8756C256MiBServiceRoleDefaultPolicyE5468F0E",
368+
"CustomCDKBucketDeployment8693BB64968944B69AAFB0CC9EB8756C256MiBServiceRoleF991ED9F"
368369
]
369370
},
370371
"Product133E85955": {

packages/@aws-cdk-testing/framework-integ/test/aws-servicecatalog/test/integ.two-products.js.snapshot/manifest.json

Lines changed: 45 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/@aws-cdk-testing/framework-integ/test/aws-servicecatalog/test/integ.two-products.js.snapshot/tree.json

Lines changed: 21 additions & 20 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/@aws-cdk-testing/framework-integ/test/aws-servicecatalog/test/integ.two-products.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ class PortfolioStack extends cdk.Stack {
3636
cloudFormationTemplate: servicecatalog.CloudFormationTemplate.fromProductStack(
3737
new TestAssetProductStack1(this, 'MyProductStack1', {
3838
assetBucket: testAssetBucket,
39+
memoryLimit: 256,
3940
}),
4041
),
4142
}],

packages/aws-cdk-lib/aws-servicecatalog/lib/private/product-stack-synthesizer.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,17 @@ export interface ProductStackSynthesizerProps {
3131
* @default - No KMS KeyId and SSE_KMS encryption cannot be used
3232
*/
3333
readonly serverSideEncryptionAwsKmsKeyId? : string;
34+
35+
/**
36+
* The amount of memory (in MiB) to allocate to the AWS Lambda function which
37+
* replicates the files from the CDK bucket to the destination bucket.
38+
*
39+
* If you are deploying large files, you will need to increase this number
40+
* accordingly.
41+
*
42+
* @default 128
43+
*/
44+
readonly memoryLimit?: number;
3445
}
3546

3647
/**
@@ -43,6 +54,7 @@ export class ProductStackSynthesizer extends cdk.StackSynthesizer {
4354
private readonly assetBucket?: IBucket;
4455
private readonly serverSideEncryption? : ServerSideEncryption;
4556
private readonly serverSideEncryptionAwsKmsKeyId? : string;
57+
private readonly memoryLimit?: number;
4658
private parentAssetBucket?: IBucket;
4759

4860
constructor(props: ProductStackSynthesizerProps) {
@@ -51,6 +63,7 @@ export class ProductStackSynthesizer extends cdk.StackSynthesizer {
5163
this.assetBucket = props.assetBucket;
5264
this.serverSideEncryption = props.serverSideEncryption;
5365
this.serverSideEncryptionAwsKmsKeyId = props.serverSideEncryptionAwsKmsKeyId;
66+
this.memoryLimit = props.memoryLimit;
5467

5568
if (this.assetBucket && !cdk.Resource.isOwnedResource(this.assetBucket)) {
5669
cdk.Annotations.of(this.parentStack).addWarningV2('@aws-cdk/aws-servicecatalog:assetsManuallyAddBucketPermissions', '[WARNING] Bucket Policy Permissions cannot be added to' +
@@ -90,6 +103,7 @@ export class ProductStackSynthesizer extends cdk.StackSynthesizer {
90103
retainOnDelete: true,
91104
serverSideEncryption: this.serverSideEncryption,
92105
serverSideEncryptionAwsKmsKeyId: this.serverSideEncryptionAwsKmsKeyId,
106+
memoryLimit: this.memoryLimit,
93107
});
94108
bucketDeployment.addSource(source);
95109

0 commit comments

Comments
 (0)