Skip to content

Commit

Permalink
Update CloudFormation Lab
Browse files Browse the repository at this point in the history
  • Loading branch information
fernando-mc committed Jun 29, 2018
1 parent 74f125c commit 15defd8
Show file tree
Hide file tree
Showing 1,636 changed files with 201 additions and 623,211 deletions.
201 changes: 201 additions & 0 deletions cloudformation/cf.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,201 @@
{
"AWSTemplateFormatVersion" : "2010-09-09",

"Resources" : {
"DynamoDBTable" : {
"Type" : "AWS::DynamoDB::Table",
"Properties" : {
"AttributeDefinitions" : [
{
"AttributeName" : "Artist",
"AttributeType" : "S"
},
{
"AttributeName" : "SongTitle",
"AttributeType" : "S"
}
],
"KeySchema" : [
{
"AttributeName" : "Artist",
"KeyType" : "HASH"
},
{
"AttributeName" : "SongTitle",
"KeyType" : "RANGE"
}
],
"ProvisionedThroughput" : {
"ReadCapacityUnits" : "5",
"WriteCapacityUnits" : "5"
},
"TableName" : "PrometheonMusic"
}
},
"LambdaExecutionRole": {
"Type": "AWS::IAM::Role",
"Properties": {
"AssumeRolePolicyDocument": {
"Version": "2012-10-17",
"Statement": [{
"Effect": "Allow",
"Principal": {"Service": ["lambda.amazonaws.com"]},
"Action": ["sts:AssumeRole"]
}]
},
"Path": "/",
"Policies": [{
"PolicyName": "root",
"PolicyDocument": {
"Version": "2012-10-17",
"Statement": [{
"Effect": "Allow",
"Action": ["logs:CreateLogGroup","logs:CreateLogStream","logs:PutLogEvents"],
"Resource": "arn:aws:logs:*:*:*"
},
{
"Effect": "Allow",
"Action": ["dynamodb:*"],
"Resource": "arn:aws:dynamodb:*:*:*"
}]
}
}],
"RoleName": "DynamoDBFullLambdaAccess"
}
},
"ListLambdaFunction": {
"Type": "AWS::Lambda::Function",
"Properties" : {
"Code" : {
"S3Bucket": "cloudassessments-lab-files",
"S3Key": "aws/s3/s3_static_site/list.zip"
},
"Description" : "The function to list data from DynamoDB",
"FunctionName" : "list",
"Handler" : "list.list",
"Role" : { "Fn::GetAtt" : ["LambdaExecutionRole", "Arn"] },
"Runtime" : "nodejs6.10"
},
"DependsOn" : ["LambdaExecutionRole"]
},
"GetLambdaFunction": {
"Type": "AWS::Lambda::Function",
"Properties" : {
"Code" : {
"S3Bucket": "cloudassessments-lab-files",
"S3Key": "aws/s3/s3_static_site/get.zip"
},
"Description" : "The function to get data from DynamoDB",
"FunctionName" : "get",
"Handler" : "get.get",
"Role" : { "Fn::GetAtt" : ["LambdaExecutionRole", "Arn"] },
"Runtime" : "nodejs6.10"
},
"DependsOn" : ["LambdaExecutionRole"]
},
"PrometheonApi": {
"Type": "AWS::ApiGateway::RestApi",
"Properties": {
"Name": "prometheon",
"Description": "API used for prometheon requests",
"FailOnWarnings" : true
}
},
"LambdaFunctionPermissionGet": {
"Type": "AWS::Lambda::Permission",
"Properties": {
"Action": "lambda:invokeFunction",
"FunctionName": {"Fn::GetAtt": ["GetLambdaFunction", "Arn"]},
"Principal": "apigateway.amazonaws.com",
"SourceArn": {"Fn::Join": ["",
["arn:aws:execute-api:", {"Ref": "AWS::Region"}, ":", {"Ref": "AWS::AccountId"}, ":", {"Ref": "PrometheonApi"}, "/*"]
]}
}
},
"LambdaFunctionPermissionList": {
"Type": "AWS::Lambda::Permission",
"Properties": {
"Action": "lambda:invokeFunction",
"FunctionName": {"Fn::GetAtt": ["ListLambdaFunction", "Arn"]},
"Principal": "apigateway.amazonaws.com",
"SourceArn": {"Fn::Join": ["",
["arn:aws:execute-api:", {"Ref": "AWS::Region"}, ":", {"Ref": "AWS::AccountId"}, ":", {"Ref": "PrometheonApi"}, "/*"]
]}
}
},
"ApiDeployment": {
"Type": "AWS::ApiGateway::Deployment",
"DependsOn": [
"ApiMethodList",
"ApiMethodGet"
],
"Properties": {
"RestApiId": {"Ref": "PrometheonApi"},
"StageName": "dev"
}
},
"PrometheonApiResourceRoot": {
"Type": "AWS::ApiGateway::Resource",
"Properties": {
"RestApiId": {"Ref": "PrometheonApi"},
"ParentId": {"Fn::GetAtt": ["PrometheonApi", "RootResourceId"]},
"PathPart": "prometheon"
}
},
"PrometheonApiResourceId": {
"DependsOn": "PrometheonApiResourceRoot",
"Type": "AWS::ApiGateway::Resource",
"Properties": {
"RestApiId": {"Ref": "PrometheonApi"},
"ParentId": { "Ref": "PrometheonApiResourceRoot"},
"PathPart": "id"
}
},
"ApiMethodList": {
"DependsOn": "LambdaFunctionPermissionList",
"Type": "AWS::ApiGateway::Method",
"Properties": {
"ResourceId": {"Ref": "PrometheonApiResourceRoot"},
"RestApiId": {"Ref": "PrometheonApi"},
"HttpMethod": "GET",
"AuthorizationType": "NONE",
"Integration": {
"Type": "AWS_PROXY",
"IntegrationHttpMethod": "POST",
"Uri": {"Fn::Join" : ["",
[
"arn:aws:apigateway:",
{"Ref": "AWS::Region"},
":lambda:path/2015-03-31/functions/",
{"Fn::GetAtt": ["ListLambdaFunction", "Arn"]},
"/invocations"
]
]}
}
}
},
"ApiMethodGet": {
"DependsOn": "LambdaFunctionPermissionGet",
"Type": "AWS::ApiGateway::Method",
"Properties": {
"ResourceId": {"Ref": "PrometheonApiResourceId"},
"RestApiId": {"Ref": "PrometheonApi"},
"HttpMethod": "GET",
"AuthorizationType": "NONE",
"Integration": {
"Type": "AWS_PROXY",
"IntegrationHttpMethod": "POST",
"Uri": {"Fn::Join" : ["",
[
"arn:aws:apigateway:",
{"Ref": "AWS::Region"},
":lambda:path/2015-03-31/functions/",
{"Fn::GetAtt": ["GetLambdaFunction", "Arn"]},
"/invocations"
]
]}
}
}
}
}
}
2 changes: 0 additions & 2 deletions cloudformation/config/config

This file was deleted.

17 changes: 0 additions & 17 deletions cloudformation/wp-site/index.php

This file was deleted.

Loading

0 comments on commit 15defd8

Please sign in to comment.