{
  "Resources": {
    "MyBucketF68F3FF0": {
      "Type": "AWS::S3::Bucket"
    },
    "MyLambdaServiceRole4539ECB6": {
      "Type": "AWS::IAM::Role",
      "Properties": {
        "AssumeRolePolicyDocument": {
          "Statement": [
            {
              "Action": "sts:AssumeRole",
              "Effect": "Allow",
              "Principal": {
                "Service": "lambda.amazonaws.com"
              }
            }
          ],
          "Version": "2012-10-17"
        },
        "ManagedPolicyArns": [
          {"Fn::Join": ["", ["arn", ":", {"Ref": "AWS::Partition"}, ":", "iam", ":", "", ":", "aws", ":", "policy", "/", "service-role/AWSLambdaBasicExecutionRole"]]}

        ]
      }
    },
    "MyLambdaServiceRoleDefaultPolicy5BBC6F68": {
      "Type": "AWS::IAM::Policy",
      "Properties": {
        "PolicyDocument": {
          "Statement": [
            {
              "Action": [
                "s3:GetObject*",
                "s3:GetBucket*",
                "s3:List*",
                "s3:PutObject*",
                "s3:DeleteObject*",
                "s3:Abort*"
              ],
              "Effect": "Allow",
              "Resource": [
                {
                  "Fn::GetAtt": [
                    "MyBucketF68F3FF0",
                    "Arn"
                  ]
                },
                {
                  "Fn::Join": [
                    "",
                    [
                      {
                        "Fn::GetAtt": [
                          "MyBucketF68F3FF0",
                          "Arn"
                        ]
                      },
                      "/",
                      "*"
                    ]
                  ]
                }
              ]
            }
          ],
          "Version": "2012-10-17"
        },
        "PolicyName": "MyLambdaServiceRoleDefaultPolicy5BBC6F68",
        "Roles": [
          {
            "Ref": "MyLambdaServiceRole4539ECB6"
          }
        ]
      }
    },
    "MyLambdaCCE802FB": {
      "Type": "AWS::Lambda::Function",
      "Properties": {
        "Code": {
          "ZipFile": "exports.handler = (_event, _context, callback) => {\n                    // tslint:disable:no-console\n                    const S3 = require('aws-sdk').S3;\n                    const client = new S3();\n                    const bucketName = process.env.BUCKET_NAME;\n                    client.upload({ Bucket: bucketName, Key: 'myfile.txt', Body: 'Hello, world' }, (err, data) => {\n                        if (err) {\n                            return callback(err);\n                        }\n                        console.log(data);\n                        return callback();\n                    });\n                }"
        },
        "Environment": {
          "Variables": {
            "BUCKET_NAME": {
              "Ref": "MyBucketF68F3FF0"
            }
          }
        },
        "Handler": "index.handler",
        "Role": {
          "Fn::GetAtt": [
            "MyLambdaServiceRole4539ECB6",
            "Arn"
          ]
        },
        "Runtime": "nodejs6.10",
        "Timeout": 30
      },
      "DependsOn": [
        "MyLambdaServiceRole4539ECB6",
        "MyLambdaServiceRoleDefaultPolicy5BBC6F68"
      ]
    }
  }
}
