in lib/aws-servicecontrolpolicy.ts [111:142]
constructor(scope: cdk.Construct, id: string, props: ServiceControlPolicyProps) {
super(scope, id);
const scpCustomResourceProvider = new cr.Provider(this, "applyScpCustomResourceProvider", {
onEventHandler: new lambda.SingletonFunction(this, "applyScpCustomResourceSingleton", {
role: props.ScpsEnabledPromise.ScpPromiseRole,
uuid: "123bh-ab28-4702-aa5a-2234235351d782",
code: new lambda.InlineCode(
fs.readFileSync("scripts/applyscp-customlambda-resource.py", {
encoding: "utf-8",
})
),
handler: "index.main",
timeout: cdk.Duration.seconds(60),
runtime: lambda.Runtime.PYTHON_3_7,
})
});
const scp = new cdk.CustomResource(this, 'ServiceControlPolicy', {
serviceToken: scpCustomResourceProvider.serviceToken,
properties: {
"policyContentInput": props.Policy,
"policyNameInput": props.PolicyName
}
});
scp.node.addDependency(props.ScpsEnabledPromise)
}