Я использую CloudFormation для создания стека, но в настоящее время у меня проблемы с процессом написания шаблона. Это мой шаблон JSON:
{
"AWSTemplateFormatVersion": "2010-09-09",
"Resources": {
"LambdaFunction": {
"Type": "AWS::Lambda::Function",
"Properties": {
"Code": {
import json
import boto3
s3 = boto3.client('s3')
def lambda_handler(event, context): # Get bucket name from the S3 event
print(event)
bucket_name = event['detail']['requestParameters']['bucketName']
# Create a bucket policy
bucket_policy = json.dumps({
s3 = boto3.client('s3')
def lambda_handler(event, context): # Get bucket name from the S3 event
print(event)
bucket_name = event['detail']['requestParameters']['bucketName']
# Create a bucket policy
bucket_policy = json.dumps({
"Version": "2012-10-17",
"Statement": [{
"Sid": "MustBeEncryptedAtRest",
"Effect": "Deny",
"Principal": "*",
"Action": "s3:PutObject",
"Resource": [
"arn:aws:s3:::{}".format(bucket_name),
"arn:aws:s3:::{}/*".format(bucket_name)
],
"Condition": {
"StringNotEquals": {
"s3:x-amz-server-side-encryption": [
"AES256",
"aws:kms"
]
}
}
},
{
"Sid": "MustBeEncryptedInTransit",
"Effect": "Deny",
"Principal": "*",
"Action": "s3:*",
"Resource": [
"arn:aws:s3:::{}".format(bucket_name),
"arn:aws:s3:::{}/*".format(bucket_name)
],
"Condition": {
"Bool": {
"aws:SecureTransport": "false"
}
}
}
]
})
}
# Set the new policy s3.put_bucket_policy(Bucket = bucket_name, Policy = bucket_policy),
"Handler": lambda_handler,
"Role": ----
"Runtime": python3 .7
}
}
, но я получаю сообщение об ошибке в строке "Code": import json
. Я даже использовал разные валидаторы JSON, но не могу понять, почему они плохо сформированы в соответствии с amazon CloudFormation. Есть идеи?