Adam Fanello
01/27/2022, 1:55 AMScript
receives bootstrapThingPolicy
as a parameter, but upon removing the stack CloudFormation immediately tries to delete BootstrapThingPolicy
, before running the onDelete
script.
const bootstrapThingPolicy = new CfnPolicy(this, "BootstrapThingPolicy", {
policyName: scope.logicalPrefixedName("bootstrap-thing-policy"),
policyDocument: bootstrapThingPolicyDocument,
});
const namespace = scope.logicalPrefixedName("").slice(0, -1);
new Script(this, "bootstrap", {
defaultFunctionProps: {
timeout: 60,
memorySize: 128,
permissions: toPermissions(
new statement.Iot()
.allow()
.toAttachPolicy()
.toAttachThingPrincipal()
.toCreateKeysAndCertificate()
.toCreateThing()
.toDeleteCertificate()
.toDeleteThing()
.toDescribeEndpoint()
.toDescribeThing()
.toDetachPolicy()
.toDetachThingPrincipal()
.toListPrincipalPolicies()
.toListThingPrincipals()
.toUpdateCertificate()
.onAllResources(),
new statement.Ssm().allow().toDeleteParameter().toPutParameter().onAllResources()
),
logRetention: RetentionDays.ONE_MONTH,
},
params: {
namespace,
boostrapThingPolicyName: bootstrapThingPolicy.policyName,
},
onCreate: "src/stacks/iot-provisioning/bootstrap-cert-script.onCreate",
onDelete: "src/stacks/iot-provisioning/bootstrap-cert-script.onDelete",
});
}
Adam Fanello
01/27/2022, 1:57 AM}).node.addDependency(bootstrapThingPolicy);
Adam Fanello
01/27/2022, 2:05 AMAdam Fanello
01/27/2022, 5:01 PM