{ "AWSTemplateFormatVersion": "2010-09-09", "Transform": "AWS::Serverless-2016-10-31", "Description": "AWS Serverless API that exposes the add, remove and get operations for a blogging platform using Amazon DynamoDB.", "Parameters": { "ShouldCreateTable": { "Type": "String", "AllowedValues": [ "true", "false" ], "Description": "If true then the DynamoDB blogging table will be created with the CloudFormation stack." }, "BlogTableName": { "Type": "String", "Description": "Name of DynamoDB table used to store the blog post. If left blank a new table will be created.", "MinLength": "0" }, "ReadCapacity": { "Type": "Number", "Description": "Read capacity for the DynamoDB blog table.", "Default": "3", "MinValue": 1 }, "WriteCapacity": { "Type": "Number", "Description": "Write capacity for the DynamoDB blog table.", "Default": "3", "MinValue": 1 } }, "Conditions": { "CreateBlogTable": { "Fn::Equals": [ { "Ref": "ShouldCreateTable" }, "true" ] }, "TableNameGenerated": { "Fn::Equals": [ { "Ref": "BlogTableName" }, "" ] } }, "Resources": { "GetBlogs": { "Type": "AWS::Serverless::Function", "Properties": { "Handler": "BlueprintBaseName.1::BlueprintBaseName._1.Functions::GetBlogsAsync", "Runtime": "dotnetcore2.1", "CodeUri": "", "Description": "Function to get a list of blogs", "MemorySize": 256, "Timeout": 30, "Role": null, "Policies": [ "AWSLambda_FullAccess", "AmazonDynamoDBFullAccess" ], "Environment": { "Variables": { "BlogTable": { "Fn::If": [ "CreateBlogTable", { "Ref": "BlogTable" }, { "Ref": "BlogTableName" } ] } } }, "Events": { "PutResource": { "Type": "Api", "Properties": { "Path": "/", "Method": "GET" } } } } }, "GetBlog": { "Type": "AWS::Serverless::Function", "Properties": { "Handler": "BlueprintBaseName.1::BlueprintBaseName._1.Functions::GetBlogAsync", "Runtime": "dotnetcore2.1", "CodeUri": "", "Description": "Function to get a single blog", "MemorySize": 256, "Timeout": 30, "Role": null, "Policies": [ "AWSLambda_FullAccess", "AmazonDynamoDBFullAccess" ], "Environment": { "Variables": { "BlogTable": { "Fn::If": [ "CreateBlogTable", { "Ref": "BlogTable" }, { "Ref": "BlogTableName" } ] } } }, "Events": { "PutResource": { "Type": "Api", "Properties": { "Path": "/{Id}", "Method": "GET" } } } } }, "AddBlog": { "Type": "AWS::Serverless::Function", "Properties": { "Handler": "BlueprintBaseName.1::BlueprintBaseName._1.Functions::AddBlogAsync", "Runtime": "dotnetcore2.1", "CodeUri": "", "Description": "Function to add a blog", "MemorySize": 256, "Timeout": 30, "Role": null, "Policies": [ "AWSLambda_FullAccess", "AmazonDynamoDBFullAccess" ], "Environment": { "Variables": { "BlogTable": { "Fn::If": [ "CreateBlogTable", { "Ref": "BlogTable" }, { "Ref": "BlogTableName" } ] } } }, "Events": { "PutResource": { "Type": "Api", "Properties": { "Path": "/", "Method": "PUT" } } } } }, "RemoveBlog": { "Type": "AWS::Serverless::Function", "Properties": { "Handler": "BlueprintBaseName.1::BlueprintBaseName._1.Functions::RemoveBlogAsync", "Runtime": "dotnetcore2.1", "CodeUri": "", "Description": "Function to remove a blog", "MemorySize": 256, "Timeout": 30, "Role": null, "Policies": [ "AWSLambda_FullAccess", "AmazonDynamoDBFullAccess" ], "Environment": { "Variables": { "BlogTable": { "Fn::If": [ "CreateBlogTable", { "Ref": "BlogTable" }, { "Ref": "BlogTableName" } ] } } }, "Events": { "PutResource": { "Type": "Api", "Properties": { "Path": "/", "Method": "DELETE" } } } } }, "BlogTable": { "Type": "AWS::DynamoDB::Table", "Condition": "CreateBlogTable", "Properties": { "TableName": { "Fn::If": [ "TableNameGenerated", { "Ref": "AWS::NoValue" }, { "Ref": "BlogTableName" } ] }, "AttributeDefinitions": [ { "AttributeName": "Id", "AttributeType": "S" } ], "KeySchema": [ { "AttributeName": "Id", "KeyType": "HASH" } ], "ProvisionedThroughput": { "ReadCapacityUnits": { "Ref": "ReadCapacity" }, "WriteCapacityUnits": { "Ref": "WriteCapacity" } } } } }, "Outputs": { "BlogTable": { "Value": { "Fn::If": [ "CreateBlogTable", { "Ref": "BlogTable" }, { "Ref": "BlogTableName" } ] } } } }