-
-
Save tututen/2c7f41ea95317f4fcafb to your computer and use it in GitHub Desktop.
lambda_with_vpc.template
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| "AWSTemplateFormatVersion": "2010-09-09", | |
| "Metadata": { | |
| "AWS::CloudFormation::Designer": { | |
| "3e8e32bf-e4b9-4a80-8eeb-b9318212429f": { | |
| "size": { | |
| "width": 170, | |
| "height": 170 | |
| }, | |
| "position": { | |
| "x": 310, | |
| "y": 50 | |
| }, | |
| "z": 0, | |
| "embeds": [ | |
| "26c39fe6-9894-4f9d-9744-2266726cfc6a", | |
| "021fe810-7434-4959-9c9d-812992d16829", | |
| "169e8a35-3190-40c8-a08b-632335b8e942" | |
| ] | |
| }, | |
| "26c39fe6-9894-4f9d-9744-2266726cfc6a": { | |
| "size": { | |
| "width": 60, | |
| "height": 60 | |
| }, | |
| "position": { | |
| "x": 330, | |
| "y": 80 | |
| }, | |
| "z": 2, | |
| "parent": "3e8e32bf-e4b9-4a80-8eeb-b9318212429f", | |
| "embeds": [] | |
| }, | |
| "169e8a35-3190-40c8-a08b-632335b8e942": { | |
| "size": { | |
| "width": 60, | |
| "height": 60 | |
| }, | |
| "position": { | |
| "x": 400, | |
| "y": 80 | |
| }, | |
| "z": 2, | |
| "parent": "3e8e32bf-e4b9-4a80-8eeb-b9318212429f", | |
| "embeds": [] | |
| }, | |
| "021fe810-7434-4959-9c9d-812992d16829": { | |
| "size": { | |
| "width": 60, | |
| "height": 60 | |
| }, | |
| "position": { | |
| "x": 400, | |
| "y": 150 | |
| }, | |
| "z": 1, | |
| "parent": "3e8e32bf-e4b9-4a80-8eeb-b9318212429f", | |
| "embeds": [], | |
| "isrelatedto": [ | |
| "26c39fe6-9894-4f9d-9744-2266726cfc6a", | |
| "1283bd7c-4d17-4023-8e57-14a5229838b6" | |
| ] | |
| }, | |
| "1283bd7c-4d17-4023-8e57-14a5229838b6": { | |
| "size": { | |
| "width": 60, | |
| "height": 60 | |
| }, | |
| "position": { | |
| "x": 500, | |
| "y": 150 | |
| }, | |
| "z": 0, | |
| "embeds": [] | |
| } | |
| } | |
| }, | |
| "Resources": { | |
| "VPC": { | |
| "Type": "AWS::EC2::VPC", | |
| "Properties": { | |
| "CidrBlock": "10.0.0.0/16" | |
| }, | |
| "Metadata": { | |
| "AWS::CloudFormation::Designer": { | |
| "id": "3e8e32bf-e4b9-4a80-8eeb-b9318212429f" | |
| } | |
| } | |
| }, | |
| "Lambda": { | |
| "Type": "AWS::Lambda::Function", | |
| "Properties": { | |
| "VpcConfig": { | |
| "SecurityGroupIds": [ | |
| { | |
| "Ref": "SecurityGroup" | |
| } | |
| ], | |
| "SubnetIds": [ | |
| { | |
| "Ref": "Subnet" | |
| } | |
| ] | |
| }, | |
| "Handler": "index.handler", | |
| "Role": { | |
| "Fn::GetAtt": [ | |
| "IAMRole", | |
| "Arn" | |
| ] | |
| }, | |
| "Runtime": "nodejs", | |
| "Timeout": "5", | |
| "Code": { | |
| "ZipFile": { | |
| "Fn::Join": [ | |
| "", | |
| [ | |
| "var response = require('cfn-response');", | |
| "exports.handler = function(event, context) {", | |
| " var input = parseInt(event.ResourceProperties.Input);", | |
| " var responseData = {Value: input * 5};", | |
| " response.send(event, context, response.SUCCESS, responseData);", | |
| "};" | |
| ] | |
| ] | |
| } | |
| } | |
| }, | |
| "Metadata": { | |
| "AWS::CloudFormation::Designer": { | |
| "id": "021fe810-7434-4959-9c9d-812992d16829" | |
| } | |
| } | |
| }, | |
| "SecurityGroup": { | |
| "Type": "AWS::EC2::SecurityGroup", | |
| "Properties": { | |
| "GroupDescription": "Security Group Description", | |
| "VpcId": { | |
| "Ref": "VPC" | |
| } | |
| }, | |
| "Metadata": { | |
| "AWS::CloudFormation::Designer": { | |
| "id": "169e8a35-3190-40c8-a08b-632335b8e942" | |
| } | |
| } | |
| }, | |
| "IAMRole": { | |
| "Type": "AWS::IAM::Role", | |
| "Properties": { | |
| "Policies": [ | |
| { | |
| "PolicyName": "LambdaWithVPCPolicy", | |
| "PolicyDocument": { | |
| "Version": "2012-10-17", | |
| "Statement": [ | |
| { | |
| "Effect": "Allow", | |
| "Action": [ | |
| "logs:CreateLogGroup", | |
| "logs:CreateLogStream", | |
| "logs:PutLogEvents" | |
| ], | |
| "Resource": "arn:aws:logs:*:*:*" | |
| }, | |
| { | |
| "Effect": "Allow", | |
| "Action": [ | |
| "ec2:CreateNetworkInterface", | |
| "ec2:DescribeNetworkInterfaces", | |
| "ec2:DetachNetworkInterface", | |
| "ec2:DeleteNetworkInterface" | |
| ], | |
| "Resource": "*" | |
| } | |
| ] | |
| } | |
| } | |
| ], | |
| "AssumeRolePolicyDocument": { | |
| "Version": "2012-10-17", | |
| "Statement": [ | |
| { | |
| "Sid": "", | |
| "Effect": "Allow", | |
| "Principal": { | |
| "Service": "lambda.amazonaws.com" | |
| }, | |
| "Action": "sts:AssumeRole" | |
| } | |
| ] | |
| } | |
| }, | |
| "Metadata": { | |
| "AWS::CloudFormation::Designer": { | |
| "id": "1283bd7c-4d17-4023-8e57-14a5229838b6" | |
| } | |
| } | |
| }, | |
| "Subnet": { | |
| "Type": "AWS::EC2::Subnet", | |
| "Properties": { | |
| "CidrBlock": "10.0.0.0/24", | |
| "VpcId": { | |
| "Ref": "VPC" | |
| } | |
| }, | |
| "Metadata": { | |
| "AWS::CloudFormation::Designer": { | |
| "id": "26c39fe6-9894-4f9d-9744-2266726cfc6a" | |
| } | |
| } | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment