in scripts/applyscp-customlambda-resource.py [0:0]
def create_scp(event, context):
policyContent = event['ResourceProperties']['policyContentInput']
policyName = event['ResourceProperties']['policyNameInput']
# Create the SCP
response = org.create_policy(
Name=policyName,
Type='SERVICE_CONTROL_POLICY',
Description='Policy to restrict access to certain regions',
Content=policyContent,
)
policyId = response['Policy']['PolicySummary']['Id']
# Attach the SCP
response = org.attach_policy(
PolicyId=policyId,
TargetId=accountNumber,
)
print(response)
return { 'PhysicalResourceId': policyId }