Skip to content

Commit

Permalink
fix: Configurator missing legacy ddk bootstrap values (#319)
Browse files Browse the repository at this point in the history
* fix: update configuratore defautl stack synthesizer

* cleanup
  • Loading branch information
malachi-constant committed May 4, 2023
1 parent 0259ace commit 300f0fc
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/config/configurator.ts
Expand Up @@ -127,10 +127,10 @@ export function getStackSynthesizer(props: getStackSynthesizerProps): cdk.IStack
qualifier: qualifier,
fileAssetsBucketName: bootstrapConfig.file_assets_bucket_name
? bootstrapConfig.file_assets_bucket_name
: undefined,
: `${prefix}-${props.environmentId}-${qualifier}-assets-${accountId}-${region}`,
bootstrapStackVersionSsmParameter: bootstrapConfig.stack_version_ssm_parameter
? bootstrapConfig.stack_version_ssm_parameter
: undefined,
: `/${prefix}/${props.environmentId}/${qualifier}/bootstrap-version`,
deployRoleArn: bootstrapConfig.deploy_role
? bootstrapConfig.deploy_role
: `arn:aws:iam::${accountId}:role/${prefix}-${props.environmentId}-${qualifier}-deploy-${accountId}-${region}`,
Expand Down
34 changes: 34 additions & 0 deletions test/base-stack.test.ts
Expand Up @@ -394,6 +394,40 @@ test("Bring Your Own Stack Synthesizer", () => {
}
});

test("Use Only Prefix to Default to DDK roles", () => {
const app = new cdk.App();

const stack = new BaseStack(app, "my-stack", {
environmentId: "dev",
config: "./test/test-config.json",
});

const expectedValues = {
qualifier: "hnb659fds",
bucketName: "ddk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}",
repositoryName: "cdk-hnb659fds-container-assets-${AWS::AccountId}-${AWS::Region}",
_deployRoleArn:
"arn:${AWS::Partition}:iam::${AWS::AccountId}:role/ddk-hnb659fds-deploy-role-${AWS::AccountId}-${AWS::Region}",
_cloudFormationExecutionRoleArn:
"arn:${AWS::Partition}:iam::${AWS::AccountId}:role/ddk-hnb659fds-cfn-exec-role-${AWS::AccountId}-${AWS::Region}",
fileAssetPublishingRoleArn:
"arn:${AWS::Partition}:iam::${AWS::AccountId}:role/ddk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}",
imageAssetPublishingRoleArn:
"arn:${AWS::Partition}:iam::${AWS::AccountId}:role/ddk-hnb659fds-image-publishing-role-${AWS::AccountId}-${AWS::Region}",
lookupRoleArn:
"arn:${AWS::Partition}:iam::${AWS::AccountId}:role/ddk-hnb659fds-lookup-role-${AWS::AccountId}-${AWS::Region}",
bucketPrefix: "",
dockerTagPrefix: "",
bootstrapStackVersionSsmParameter: "/ddk/dev/hnb659fds/bootstrap-version",
};
for (const attribute in expectedValues) {
assert(
stack.synthesizer[attribute as keyof typeof stack.synthesizer] ===
expectedValues[attribute as keyof typeof expectedValues],
);
}
});

test("Additional Stack Props", () => {
const app = new cdk.App();

Expand Down
5 changes: 4 additions & 1 deletion test/test-config.json
Expand Up @@ -21,7 +21,10 @@
"props": {
"my_unique_config_property": "foobar"
},
"unsupported_property": "barfoo"
"unsupported_property": "barfoo",
"bootstrap": {
"prefix": "ddk"
}
},
"prod": {
"account": "222222222222",
Expand Down

0 comments on commit 300f0fc

Please sign in to comment.