Skip to content

Instantly share code, notes, and snippets.

@richardsonlima
Created August 16, 2020 22:36
Show Gist options
  • Save richardsonlima/684dad0a03de8ffae4791ba70de63813 to your computer and use it in GitHub Desktop.
Save richardsonlima/684dad0a03de8ffae4791ba70de63813 to your computer and use it in GitHub Desktop.
{
"Resources": {
"queue276F7297": {
"Type": "AWS::SQS::Queue",
"Properties": {
"QueueName": "queue"
},
"Metadata": {
"aws:cdk:path": "ServerlessStackStack/queue/Resource"
}
},
"table8235A42E": {
"Type": "AWS::DynamoDB::Table",
"Properties": {
"KeySchema": [
{
"AttributeName": "id",
"KeyType": "HASH"
}
],
"AttributeDefinitions": [
{
"AttributeName": "id",
"AttributeType": "N"
}
],
"ProvisionedThroughput": {
"ReadCapacityUnits": 5,
"WriteCapacityUnits": 5
}
},
"UpdateReplacePolicy": "Retain",
"DeletionPolicy": "Retain",
"Metadata": {
"aws:cdk:path": "ServerlessStackStack/table/Resource"
}
},
"publishFunctionServiceRole779A3536": {
"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"
]
]
}
]
},
"Metadata": {
"aws:cdk:path": "ServerlessStackStack/publishFunction/ServiceRole/Resource"
}
},
"publishFunctionServiceRoleDefaultPolicy57B1EA19": {
"Type": "AWS::IAM::Policy",
"Properties": {
"PolicyDocument": {
"Statement": [
{
"Action": [
"sqs:SendMessage",
"sqs:GetQueueAttributes",
"sqs:GetQueueUrl"
],
"Effect": "Allow",
"Resource": {
"Fn::GetAtt": [
"queue276F7297",
"Arn"
]
}
}
],
"Version": "2012-10-17"
},
"PolicyName": "publishFunctionServiceRoleDefaultPolicy57B1EA19",
"Roles": [
{
"Ref": "publishFunctionServiceRole779A3536"
}
]
},
"Metadata": {
"aws:cdk:path": "ServerlessStackStack/publishFunction/ServiceRole/DefaultPolicy/Resource"
}
},
"publishFunction0955FBF8": {
"Type": "AWS::Lambda::Function",
"Properties": {
"Code": {
"S3Bucket": {
"Ref": "AssetParameters7f810969731f35a84999fb2df6994a365001650983102aa57a8e04af29134fcdS3BucketEB74C09E"
},
"S3Key": {
"Fn::Join": [
"",
[
{
"Fn::Select": [
0,
{
"Fn::Split": [
"||",
{
"Ref": "AssetParameters7f810969731f35a84999fb2df6994a365001650983102aa57a8e04af29134fcdS3VersionKey04255F4F"
}
]
}
]
},
{
"Fn::Select": [
1,
{
"Fn::Split": [
"||",
{
"Ref": "AssetParameters7f810969731f35a84999fb2df6994a365001650983102aa57a8e04af29134fcdS3VersionKey04255F4F"
}
]
}
]
}
]
]
}
},
"Handler": "index.handler",
"Role": {
"Fn::GetAtt": [
"publishFunctionServiceRole779A3536",
"Arn"
]
},
"Runtime": "nodejs10.x",
"Environment": {
"Variables": {
"QUEUE_URL": {
"Ref": "queue276F7297"
}
}
}
},
"DependsOn": [
"publishFunctionServiceRoleDefaultPolicy57B1EA19",
"publishFunctionServiceRole779A3536"
],
"Metadata": {
"aws:cdk:path": "ServerlessStackStack/publishFunction/Resource",
"aws:asset:path": "asset.7f810969731f35a84999fb2df6994a365001650983102aa57a8e04af29134fcd",
"aws:asset:property": "Code"
}
},
"apiC8550315": {
"Type": "AWS::ApiGateway::RestApi",
"Properties": {
"Name": "api"
},
"Metadata": {
"aws:cdk:path": "ServerlessStackStack/api/Resource"
}
},
"apiCloudWatchRoleAC81D93E": {
"Type": "AWS::IAM::Role",
"Properties": {
"AssumeRolePolicyDocument": {
"Statement": [
{
"Action": "sts:AssumeRole",
"Effect": "Allow",
"Principal": {
"Service": "apigateway.amazonaws.com"
}
}
],
"Version": "2012-10-17"
},
"ManagedPolicyArns": [
{
"Fn::Join": [
"",
[
"arn:",
{
"Ref": "AWS::Partition"
},
":iam::aws:policy/service-role/AmazonAPIGatewayPushToCloudWatchLogs"
]
]
}
]
},
"Metadata": {
"aws:cdk:path": "ServerlessStackStack/api/CloudWatchRole/Resource"
}
},
"apiAccount57E28B43": {
"Type": "AWS::ApiGateway::Account",
"Properties": {
"CloudWatchRoleArn": {
"Fn::GetAtt": [
"apiCloudWatchRoleAC81D93E",
"Arn"
]
}
},
"DependsOn": [
"apiC8550315"
],
"Metadata": {
"aws:cdk:path": "ServerlessStackStack/api/Account"
}
},
"apiDeployment149F129447fad4ecb3fd9eb45e3c57629a3ce366": {
"Type": "AWS::ApiGateway::Deployment",
"Properties": {
"RestApiId": {
"Ref": "apiC8550315"
},
"Description": "Automatically created by the RestApi construct"
},
"DependsOn": [
"apiGETECF0BD67"
],
"Metadata": {
"aws:cdk:path": "ServerlessStackStack/api/Deployment/Resource"
}
},
"apiDeploymentStagedev96712F43": {
"Type": "AWS::ApiGateway::Stage",
"Properties": {
"RestApiId": {
"Ref": "apiC8550315"
},
"DeploymentId": {
"Ref": "apiDeployment149F129447fad4ecb3fd9eb45e3c57629a3ce366"
},
"StageName": "dev"
},
"Metadata": {
"aws:cdk:path": "ServerlessStackStack/api/DeploymentStage.dev/Resource"
}
},
"apiGETApiPermissionServerlessStackStackapi3414ED78GET0BFE12FF": {
"Type": "AWS::Lambda::Permission",
"Properties": {
"Action": "lambda:InvokeFunction",
"FunctionName": {
"Fn::GetAtt": [
"publishFunction0955FBF8",
"Arn"
]
},
"Principal": "apigateway.amazonaws.com",
"SourceArn": {
"Fn::Join": [
"",
[
"arn:",
{
"Ref": "AWS::Partition"
},
":execute-api:",
{
"Ref": "AWS::Region"
},
":",
{
"Ref": "AWS::AccountId"
},
":",
{
"Ref": "apiC8550315"
},
"/",
{
"Ref": "apiDeploymentStagedev96712F43"
},
"/GET/"
]
]
}
},
"Metadata": {
"aws:cdk:path": "ServerlessStackStack/api/Default/GET/ApiPermission.ServerlessStackStackapi3414ED78.GET.."
}
},
"apiGETApiPermissionTestServerlessStackStackapi3414ED78GET2FE6D074": {
"Type": "AWS::Lambda::Permission",
"Properties": {
"Action": "lambda:InvokeFunction",
"FunctionName": {
"Fn::GetAtt": [
"publishFunction0955FBF8",
"Arn"
]
},
"Principal": "apigateway.amazonaws.com",
"SourceArn": {
"Fn::Join": [
"",
[
"arn:",
{
"Ref": "AWS::Partition"
},
":execute-api:",
{
"Ref": "AWS::Region"
},
":",
{
"Ref": "AWS::AccountId"
},
":",
{
"Ref": "apiC8550315"
},
"/test-invoke-stage/GET/"
]
]
}
},
"Metadata": {
"aws:cdk:path": "ServerlessStackStack/api/Default/GET/ApiPermission.Test.ServerlessStackStackapi3414ED78.GET.."
}
},
"apiGETECF0BD67": {
"Type": "AWS::ApiGateway::Method",
"Properties": {
"HttpMethod": "GET",
"ResourceId": {
"Fn::GetAtt": [
"apiC8550315",
"RootResourceId"
]
},
"RestApiId": {
"Ref": "apiC8550315"
},
"AuthorizationType": "NONE",
"Integration": {
"IntegrationHttpMethod": "POST",
"Type": "AWS_PROXY",
"Uri": {
"Fn::Join": [
"",
[
"arn:",
{
"Ref": "AWS::Partition"
},
":apigateway:",
{
"Ref": "AWS::Region"
},
":lambda:path/2015-03-31/functions/",
{
"Fn::GetAtt": [
"publishFunction0955FBF8",
"Arn"
]
},
"/invocations"
]
]
}
}
},
"Metadata": {
"aws:cdk:path": "ServerlessStackStack/api/Default/GET/Resource"
}
},
"subscribeFunctionServiceRoleE1E26A6E": {
"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"
]
]
}
]
},
"Metadata": {
"aws:cdk:path": "ServerlessStackStack/subscribeFunction/ServiceRole/Resource"
}
},
"subscribeFunctionServiceRoleDefaultPolicyA1C1D645": {
"Type": "AWS::IAM::Policy",
"Properties": {
"PolicyDocument": {
"Statement": [
{
"Action": [
"sqs:ReceiveMessage",
"sqs:ChangeMessageVisibility",
"sqs:GetQueueUrl",
"sqs:DeleteMessage",
"sqs:GetQueueAttributes"
],
"Effect": "Allow",
"Resource": {
"Fn::GetAtt": [
"queue276F7297",
"Arn"
]
}
},
{
"Action": "dynamodb:PutItem",
"Effect": "Allow",
"Resource": [
{
"Fn::GetAtt": [
"table8235A42E",
"Arn"
]
},
{
"Ref": "AWS::NoValue"
}
]
}
],
"Version": "2012-10-17"
},
"PolicyName": "subscribeFunctionServiceRoleDefaultPolicyA1C1D645",
"Roles": [
{
"Ref": "subscribeFunctionServiceRoleE1E26A6E"
}
]
},
"Metadata": {
"aws:cdk:path": "ServerlessStackStack/subscribeFunction/ServiceRole/DefaultPolicy/Resource"
}
},
"subscribeFunction1FA97757": {
"Type": "AWS::Lambda::Function",
"Properties": {
"Code": {
"S3Bucket": {
"Ref": "AssetParameters74cc2d35754eea9df5d0110831c9ba5ec416db8e8c171b0e195ef48fe5ad57b1S3Bucket15325D83"
},
"S3Key": {
"Fn::Join": [
"",
[
{
"Fn::Select": [
0,
{
"Fn::Split": [
"||",
{
"Ref": "AssetParameters74cc2d35754eea9df5d0110831c9ba5ec416db8e8c171b0e195ef48fe5ad57b1S3VersionKeyA6810A34"
}
]
}
]
},
{
"Fn::Select": [
1,
{
"Fn::Split": [
"||",
{
"Ref": "AssetParameters74cc2d35754eea9df5d0110831c9ba5ec416db8e8c171b0e195ef48fe5ad57b1S3VersionKeyA6810A34"
}
]
}
]
}
]
]
}
},
"Handler": "index.handler",
"Role": {
"Fn::GetAtt": [
"subscribeFunctionServiceRoleE1E26A6E",
"Arn"
]
},
"Runtime": "nodejs10.x",
"Environment": {
"Variables": {
"QUEUE_URL": {
"Ref": "queue276F7297"
},
"TABLE_NAME": {
"Ref": "table8235A42E"
}
}
}
},
"DependsOn": [
"subscribeFunctionServiceRoleDefaultPolicyA1C1D645",
"subscribeFunctionServiceRoleE1E26A6E"
],
"Metadata": {
"aws:cdk:path": "ServerlessStackStack/subscribeFunction/Resource",
"aws:asset:path": "asset.74cc2d35754eea9df5d0110831c9ba5ec416db8e8c171b0e195ef48fe5ad57b1",
"aws:asset:property": "Code"
}
},
"subscribeFunctionSqsEventSourceServerlessStackStackqueueDE23BF8294529142": {
"Type": "AWS::Lambda::EventSourceMapping",
"Properties": {
"EventSourceArn": {
"Fn::GetAtt": [
"queue276F7297",
"Arn"
]
},
"FunctionName": {
"Ref": "subscribeFunction1FA97757"
}
},
"Metadata": {
"aws:cdk:path": "ServerlessStackStack/subscribeFunction/SqsEventSource:ServerlessStackStackqueueDE23BF82/Resource"
}
}
},
"Parameters": {
"AssetParameters7f810969731f35a84999fb2df6994a365001650983102aa57a8e04af29134fcdS3BucketEB74C09E": {
"Type": "String",
"Description": "S3 bucket for asset \"7f810969731f35a84999fb2df6994a365001650983102aa57a8e04af29134fcd\""
},
"AssetParameters7f810969731f35a84999fb2df6994a365001650983102aa57a8e04af29134fcdS3VersionKey04255F4F": {
"Type": "String",
"Description": "S3 key for asset version \"7f810969731f35a84999fb2df6994a365001650983102aa57a8e04af29134fcd\""
},
"AssetParameters7f810969731f35a84999fb2df6994a365001650983102aa57a8e04af29134fcdArtifactHash1A31DC85": {
"Type": "String",
"Description": "Artifact hash for asset \"7f810969731f35a84999fb2df6994a365001650983102aa57a8e04af29134fcd\""
},
"AssetParameters74cc2d35754eea9df5d0110831c9ba5ec416db8e8c171b0e195ef48fe5ad57b1S3Bucket15325D83": {
"Type": "String",
"Description": "S3 bucket for asset \"74cc2d35754eea9df5d0110831c9ba5ec416db8e8c171b0e195ef48fe5ad57b1\""
},
"AssetParameters74cc2d35754eea9df5d0110831c9ba5ec416db8e8c171b0e195ef48fe5ad57b1S3VersionKeyA6810A34": {
"Type": "String",
"Description": "S3 key for asset version \"74cc2d35754eea9df5d0110831c9ba5ec416db8e8c171b0e195ef48fe5ad57b1\""
},
"AssetParameters74cc2d35754eea9df5d0110831c9ba5ec416db8e8c171b0e195ef48fe5ad57b1ArtifactHash5C191C5A": {
"Type": "String",
"Description": "Artifact hash for asset \"74cc2d35754eea9df5d0110831c9ba5ec416db8e8c171b0e195ef48fe5ad57b1\""
}
},
"Outputs": {
"apiEndpoint9349E63C": {
"Value": {
"Fn::Join": [
"",
[
"https://",
{
"Ref": "apiC8550315"
},
".execute-api.",
{
"Ref": "AWS::Region"
},
".",
{
"Ref": "AWS::URLSuffix"
},
"/",
{
"Ref": "apiDeploymentStagedev96712F43"
},
"/"
]
]
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment