Skip to content

Commit

Permalink
feat(servicecatalog): ProductStack memoryLimit prop (#30105)
Browse files Browse the repository at this point in the history
### 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*
  • Loading branch information
nmussy committed May 15, 2024
1 parent a53517c commit 4b6dc8c
Show file tree
Hide file tree
Showing 8 changed files with 136 additions and 42 deletions.

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

Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
"Value": "true"
},
{
"Key": "aws-cdk:cr-owned:8a3b3620",
"Key": "aws-cdk:cr-owned:978d2e9b",
"Value": "true"
}
]
Expand Down Expand Up @@ -130,12 +130,12 @@
"Description": "/opt/awscli/aws"
}
},
"TestAssetBucketProductAssetsDeploymentCustomResource5F81E30F": {
"TestAssetBucketProductAssetsDeploymentCustomResource256MiBB5A849A6": {
"Type": "Custom::CDKBucketDeployment",
"Properties": {
"ServiceToken": {
"Fn::GetAtt": [
"CustomCDKBucketDeployment8693BB64968944B69AAFB0CC9EB8756C81C01536",
"CustomCDKBucketDeployment8693BB64968944B69AAFB0CC9EB8756C256MiB5F7BD223",
"Arn"
]
},
Expand Down Expand Up @@ -217,7 +217,7 @@
"CustomS3AutoDeleteObjectsCustomResourceProviderRole3B1BD092"
]
},
"CustomCDKBucketDeployment8693BB64968944B69AAFB0CC9EB8756CServiceRole89A01265": {
"CustomCDKBucketDeployment8693BB64968944B69AAFB0CC9EB8756C256MiBServiceRoleF991ED9F": {
"Type": "AWS::IAM::Role",
"Properties": {
"AssumeRolePolicyDocument": {
Expand Down Expand Up @@ -248,7 +248,7 @@
]
}
},
"CustomCDKBucketDeployment8693BB64968944B69AAFB0CC9EB8756CServiceRoleDefaultPolicy88902FDF": {
"CustomCDKBucketDeployment8693BB64968944B69AAFB0CC9EB8756C256MiBServiceRoleDefaultPolicyE5468F0E": {
"Type": "AWS::IAM::Policy",
"Properties": {
"PolicyDocument": {
Expand Down Expand Up @@ -327,15 +327,15 @@
],
"Version": "2012-10-17"
},
"PolicyName": "CustomCDKBucketDeployment8693BB64968944B69AAFB0CC9EB8756CServiceRoleDefaultPolicy88902FDF",
"PolicyName": "CustomCDKBucketDeployment8693BB64968944B69AAFB0CC9EB8756C256MiBServiceRoleDefaultPolicyE5468F0E",
"Roles": [
{
"Ref": "CustomCDKBucketDeployment8693BB64968944B69AAFB0CC9EB8756CServiceRole89A01265"
"Ref": "CustomCDKBucketDeployment8693BB64968944B69AAFB0CC9EB8756C256MiBServiceRoleF991ED9F"
}
]
}
},
"CustomCDKBucketDeployment8693BB64968944B69AAFB0CC9EB8756C81C01536": {
"CustomCDKBucketDeployment8693BB64968944B69AAFB0CC9EB8756C256MiB5F7BD223": {
"Type": "AWS::Lambda::Function",
"Properties": {
"Code": {
Expand All @@ -353,18 +353,19 @@
"Ref": "TestAssetBucketProductAssetsDeploymentAwsCliLayerD1E52C82"
}
],
"MemorySize": 256,
"Role": {
"Fn::GetAtt": [
"CustomCDKBucketDeployment8693BB64968944B69AAFB0CC9EB8756CServiceRole89A01265",
"CustomCDKBucketDeployment8693BB64968944B69AAFB0CC9EB8756C256MiBServiceRoleF991ED9F",
"Arn"
]
},
"Runtime": "python3.9",
"Timeout": 900
},
"DependsOn": [
"CustomCDKBucketDeployment8693BB64968944B69AAFB0CC9EB8756CServiceRoleDefaultPolicy88902FDF",
"CustomCDKBucketDeployment8693BB64968944B69AAFB0CC9EB8756CServiceRole89A01265"
"CustomCDKBucketDeployment8693BB64968944B69AAFB0CC9EB8756C256MiBServiceRoleDefaultPolicyE5468F0E",
"CustomCDKBucketDeployment8693BB64968944B69AAFB0CC9EB8756C256MiBServiceRoleF991ED9F"
]
},
"Product133E85955": {
Expand Down

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

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

Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ class PortfolioStack extends cdk.Stack {
cloudFormationTemplate: servicecatalog.CloudFormationTemplate.fromProductStack(
new TestAssetProductStack1(this, 'MyProductStack1', {
assetBucket: testAssetBucket,
memoryLimit: 256,
}),
),
}],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,17 @@ export interface ProductStackSynthesizerProps {
* @default - No KMS KeyId and SSE_KMS encryption cannot be used
*/
readonly serverSideEncryptionAwsKmsKeyId? : string;

/**
* The amount of memory (in MiB) to allocate to the AWS Lambda function which
* replicates the files from the CDK bucket to the destination bucket.
*
* If you are deploying large files, you will need to increase this number
* accordingly.
*
* @default 128
*/
readonly memoryLimit?: number;
}

/**
Expand All @@ -43,6 +54,7 @@ export class ProductStackSynthesizer extends cdk.StackSynthesizer {
private readonly assetBucket?: IBucket;
private readonly serverSideEncryption? : ServerSideEncryption;
private readonly serverSideEncryptionAwsKmsKeyId? : string;
private readonly memoryLimit?: number;
private parentAssetBucket?: IBucket;

constructor(props: ProductStackSynthesizerProps) {
Expand All @@ -51,6 +63,7 @@ export class ProductStackSynthesizer extends cdk.StackSynthesizer {
this.assetBucket = props.assetBucket;
this.serverSideEncryption = props.serverSideEncryption;
this.serverSideEncryptionAwsKmsKeyId = props.serverSideEncryptionAwsKmsKeyId;
this.memoryLimit = props.memoryLimit;

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

Expand Down

0 comments on commit 4b6dc8c

Please sign in to comment.