mirror of
https://github.com/Sea-Haven-Industries/shoc-frontend-new.git
synced 2026-10-07 10:28:59 +00:00
fix(cdk): keep the auto-delete Lambda description off the site bucket (SH-300) (#179)
* fix(cdk): keep the auto-delete Lambda description off the site bucket * style(cdk): format the auto-delete Lambda path check
This commit is contained in:
parent
5b08bfa57b
commit
b24e6f3b9a
2 changed files with 24 additions and 1 deletions
|
|
@ -369,9 +369,25 @@ export class FrontendStack extends Stack {
|
||||||
node.cfnResourceType === "AWS::IAM::Role" &&
|
node.cfnResourceType === "AWS::IAM::Role" &&
|
||||||
node.node.path.endsWith("/Custom::S3AutoDeleteObjectsCustomResourceProvider/Role"),
|
node.node.path.endsWith("/Custom::S3AutoDeleteObjectsCustomResourceProvider/Role"),
|
||||||
);
|
);
|
||||||
if (!rolePolicy || !autoDeleteProviderRole) {
|
const autoDeleteProviderHandler = this.node
|
||||||
|
.findAll()
|
||||||
|
.find(
|
||||||
|
(node): node is CfnResource =>
|
||||||
|
node instanceof CfnResource &&
|
||||||
|
node.cfnResourceType === "AWS::Lambda::Function" &&
|
||||||
|
node.node.path.endsWith("/Custom::S3AutoDeleteObjectsCustomResourceProvider/Handler"),
|
||||||
|
);
|
||||||
|
if (!rolePolicy || !autoDeleteProviderRole || !autoDeleteProviderHandler) {
|
||||||
throw new Error("Terraform adoption outputs require deploy and auto-delete roles.");
|
throw new Error("Terraform adoption outputs require deploy and auto-delete roles.");
|
||||||
}
|
}
|
||||||
|
// The provider Lambda stays unconditioned so it remains after
|
||||||
|
// ManageSiteInfrastructure=false. Its generated Description Refs the
|
||||||
|
// conditioned bucket and CloudFormation rejects that when the condition
|
||||||
|
// is false. Keep a static description.
|
||||||
|
autoDeleteProviderHandler.addPropertyOverride(
|
||||||
|
"Description",
|
||||||
|
"Lambda function for auto-deleting objects in the site S3 bucket.",
|
||||||
|
);
|
||||||
|
|
||||||
const recordName = domainNames[0];
|
const recordName = domainNames[0];
|
||||||
gateOutput(
|
gateOutput(
|
||||||
|
|
|
||||||
|
|
@ -189,6 +189,13 @@ test("adoption mode requires ManageSiteInfrastructure and gates transferred reso
|
||||||
for (const [outputName, output] of Object.entries(template.Outputs)) {
|
for (const [outputName, output] of Object.entries(template.Outputs)) {
|
||||||
assert.equal(output.Condition, CONDITION, outputName);
|
assert.equal(output.Condition, CONDITION, outputName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const [, autoDeleteHandler] = entriesByType(template, "AWS::Lambda::Function")[0];
|
||||||
|
assert.equal(
|
||||||
|
autoDeleteHandler.Properties.Description,
|
||||||
|
"Lambda function for auto-deleting objects in the site S3 bucket.",
|
||||||
|
);
|
||||||
|
assert.equal(typeof autoDeleteHandler.Properties.Description, "string");
|
||||||
});
|
});
|
||||||
|
|
||||||
test("normal mode is unchanged: destructive cleanup, StringLike trust, no boundary, tag, or parameter", () => {
|
test("normal mode is unchanged: destructive cleanup, StringLike trust, no boundary, tag, or parameter", () => {
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue