Skip to content

Instantly share code, notes, and snippets.

@jakul
Created July 4, 2016 11:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jakul/88532fca517f3899b97dc956d661a7b7 to your computer and use it in GitHub Desktop.
Save jakul/88532fca517f3899b97dc956d661a7b7 to your computer and use it in GitHub Desktop.
AWS CloudFormation template regex wrong
{
"Outputs": {
"ClioutputApigatewayFirstappSampleApi": {
"Value": {
"Fn::Join": [
"",
[
"https://",
{
"Ref": "FirstappSampleApi"
},
".execute-api.",
{
"Ref": "AWS::Region"
},
".amazonaws.com/",
{
"Ref": "Stage"
}
]
]
}
},
"ClioutputLambdaFirstappHelloworld": {
"Value": {
"Ref": "HelloworldCurrentalias"
}
}
},
"Parameters": {
"CodeBucket": {
"Description": "Bucket where the code is located.",
"Type": "String"
},
"HelloworldS3Version": {
"Type": "String"
},
"Region": {
"Description": "AWS Region",
"Type": "String"
},
"Stage": {
"Default": "dev",
"Description": "Name of the Stage",
"Type": "String"
},
"VersionS3Version": {
"Type": "String"
}
},
"Resources": {
"ContribLambdasVersion": {
"DependsOn": [
"VersionRole"
],
"Properties": {
"Code": {
"S3Bucket": {
"Ref": "CodeBucket"
},
"S3Key": "contrib_lambdas_version.zip",
"S3ObjectVersion": {
"Ref": "VersionS3Version"
}
},
"Description": "Publishes new versions of Lambdas.",
"Handler": "version.handler",
"MemorySize": 128,
"Role": {
"Fn::GetAtt": [
"VersionRole",
"Arn"
]
},
"Runtime": "python2.7",
"Timeout": 300
},
"Type": "AWS::Lambda::Function"
},
"FirstappHelloworld": {
"DependsOn": [
"HelloworldRole"
],
"Properties": {
"Code": {
"S3Bucket": {
"Ref": "CodeBucket"
},
"S3Key": "firstapp_helloworld.zip",
"S3ObjectVersion": {
"Ref": "HelloworldS3Version"
}
},
"Description": "",
"Handler": "code.handler",
"MemorySize": 128,
"Role": {
"Fn::GetAtt": [
"HelloworldRole",
"Arn"
]
},
"Runtime": "python2.7",
"Timeout": 3
},
"Type": "AWS::Lambda::Function"
},
"FirstappSampleApi": {
"Properties": {
"Description": "",
"Name": {
"Fn::Join": [
"-",
[
"sample_api",
{
"Ref": "Stage"
}
]
]
}
},
"Type": "AWS::ApiGateway::RestApi"
},
"HelloworldCurrentalias": {
"DependsOn": [
"HelloworldVersion"
],
"Properties": {
"FunctionName": {
"Ref": "FirstappHelloworld"
},
"FunctionVersion": {
"Fn::GetAtt": [
"HelloworldVersion",
"Version"
]
},
"Name": "current"
},
"Type": "AWS::Lambda::Alias"
},
"HelloworldRole": {
"Properties": {
"AssumeRolePolicyDocument": {
"Statement": [
{
"Action": [
"sts:AssumeRole"
],
"Effect": "Allow",
"Principal": {
"Service": [
"lambda.amazonaws.com"
]
}
}
],
"Version": "2012-10-17"
},
"Policies": [
{
"PolicyDocument": {
"Statement": [
{
"Action": [
"lambda:InvokeFunction"
],
"Effect": "Allow",
"Resource": [
"*"
]
},
{
"Action": [
"logs:CreateLogGroup",
"logs:CreateLogStream",
"logs:PutLogEvents"
],
"Effect": "Allow",
"Resource": "arn:aws:logs:*:*:*"
}
],
"Version": "2012-10-17"
},
"PolicyName": "HelloworldLogsPolicy"
}
]
},
"Type": "AWS::IAM::Role"
},
"HelloworldVersion": {
"DependsOn": [
"VersionCurrentalias",
"FirstappHelloworld"
],
"Properties": {
"FunctionName": {
"Ref": "FirstappHelloworld"
},
"S3ObjectVersion": {
"Ref": "HelloworldS3Version"
},
"ServiceToken": {
"Ref": "VersionCurrentalias"
}
},
"Type": "Custom::LambdaVersion"
},
"SampleApiDeploymentAf2Df63D": {
"DependsOn": [
"SampleApiEventPost"
],
"Properties": {
"RestApiId": {
"Ref": "FirstappSampleApi"
},
"StageName": {
"Ref": "Stage"
}
},
"Type": "AWS::ApiGateway::Deployment"
},
"SampleApiEventPost": {
"Properties": {
"ApiKeyRequired": false,
"AuthorizationType": "NONE",
"HttpMethod": "POST",
"Integration": {
"Credentials": {
"Fn::GetAtt": [
"SampleApiRole",
"Arn"
]
},
"IntegrationHttpMethod": "POST",
"IntegrationResponses": [
{
"SelectionPattern": "",
"StatusCode": "201"
},
{
"SelectionPattern": ".*\"status\":400.*",
"StatusCode": "400"
},
{
"SelectionPattern": "*.\\\"errorMessage\\\".*",
"StatusCode": "500"
}
],
"RequestTemplates": {},
"Type": "AWS",
"Uri": {
"Fn::Join": [
"",
[
"arn:aws:apigateway:",
{
"Ref": "AWS::Region"
},
":lambda:path/2015-03-31/functions/",
{
"Ref": "HelloworldCurrentalias"
},
"/invocations"
]
]
}
},
"MethodResponses": [
{
"StatusCode": "201"
},
{
"StatusCode": "400"
},
{
"StatusCode": "500"
}
],
"ResourceId": {
"Ref": "SampleApiResourceEvent"
},
"RestApiId": {
"Ref": "FirstappSampleApi"
}
},
"Type": "AWS::ApiGateway::Method"
},
"SampleApiResourceEvent": {
"Properties": {
"ParentId": {
"Fn::GetAtt": [
"FirstappSampleApi",
"RootResourceId"
]
},
"PathPart": "event",
"RestApiId": {
"Ref": "FirstappSampleApi"
}
},
"Type": "AWS::ApiGateway::Resource"
},
"SampleApiRole": {
"Properties": {
"AssumeRolePolicyDocument": {
"Statement": [
{
"Action": [
"sts:AssumeRole"
],
"Effect": "Allow",
"Principal": {
"Service": [
"apigateway.amazonaws.com"
]
}
}
],
"Version": "2012-10-17"
},
"Policies": [
{
"PolicyDocument": {
"Statement": [
{
"Action": [
"lambda:InvokeFunction"
],
"Effect": "Allow",
"Resource": [
"*"
]
}
],
"Version": "2012-10-17"
},
"PolicyName": "SampleApiRolePolicy"
}
]
},
"Type": "AWS::IAM::Role"
},
"VersionCurrentalias": {
"DependsOn": [
"VersionVersion"
],
"Properties": {
"FunctionName": {
"Ref": "ContribLambdasVersion"
},
"FunctionVersion": {
"Fn::GetAtt": [
"VersionVersion",
"Version"
]
},
"Name": "current"
},
"Type": "AWS::Lambda::Alias"
},
"VersionRole": {
"Properties": {
"AssumeRolePolicyDocument": {
"Statement": [
{
"Action": [
"sts:AssumeRole"
],
"Effect": "Allow",
"Principal": {
"Service": [
"lambda.amazonaws.com"
]
}
}
],
"Version": "2012-10-17"
},
"Policies": [
{
"PolicyDocument": {
"Statement": [
{
"Action": [
"lambda:InvokeFunction"
],
"Effect": "Allow",
"Resource": [
"*"
]
},
{
"Action": [
"logs:CreateLogGroup",
"logs:CreateLogStream",
"logs:PutLogEvents"
],
"Effect": "Allow",
"Resource": "arn:aws:logs:*:*:*"
}
],
"Version": "2012-10-17"
},
"PolicyName": "VersionLogsPolicy"
},
{
"PolicyDocument": {
"Statement": [
{
"Action": [
"lambda:PublishVersion",
"lambda:GetFunction"
],
"Effect": "Allow",
"Resource": "arn:aws:lambda:*:*:*"
}
],
"Version": "2012-10-17"
},
"PolicyName": "VersionManageVersionPolicy"
}
]
},
"Type": "AWS::IAM::Role"
},
"VersionVersion": {
"DependsOn": [
"ContribLambdasVersion",
"ContribLambdasVersion"
],
"Properties": {
"FunctionName": {
"Ref": "ContribLambdasVersion"
},
"S3ObjectVersion": {
"Ref": "VersionS3Version"
},
"ServiceToken": {
"Fn::GetAtt": [
"ContribLambdasVersion",
"Arn"
]
}
},
"Type": "Custom::LambdaVersion"
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment