Last active
March 4, 2019 17:53
-
-
Save kevinmmartins/ceb6ecaac64fb6e4324f10cf939ef16f to your computer and use it in GitHub Desktop.
Cloudformation to a Java application using Beanstalk and DynamoDB
This file contains 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", | |
"Parameters": { | |
"ApplicationBucket": { | |
"Type": "String", | |
"Description": "The bucket name with artifact" | |
}, | |
"ApiKey": { | |
"Type": "String", | |
"Description": "The API key to make requests to server" | |
}, | |
"ThroughputDynamo": { | |
"Type": "Number", | |
"Default": "5", | |
"Description": "The value of dynamo throughput" | |
}, | |
"AWSRegion": { | |
"Type": "String", | |
"Description": "AWS Region", | |
"Default": "us-east-1" | |
}, | |
"AWSSecretKey": { | |
"Type": "String", | |
"Description": "The secret value" | |
}, | |
"AWSAccessKey": { | |
"Type": "String", | |
"Description": "The access value" | |
}, | |
"MinInstances": { | |
"Type": "Number", | |
"Default": "1", | |
"Description": "The min value of Application instances" | |
}, | |
"MaxInstances": { | |
"Type": "Number", | |
"Default": "1", | |
"Description": "The max value of Application instances" | |
} | |
}, | |
"Outputs": { | |
"ApplicationTableARN": { | |
"Description": "ARN of the Application Table", | |
"Value": { | |
"Fn::GetAtt": [ | |
"ApplicationTable", | |
"Arn" | |
] | |
} | |
} | |
}, | |
"Resources": { | |
"ApplicationTable": { | |
"Type": "AWS::DynamoDB::Table", | |
"Properties": { | |
"TableName": "IncidentByUser", | |
"AttributeDefinitions": [ | |
{ | |
"AttributeName": "Protocol", | |
"AttributeType": "N" | |
}, | |
{ | |
"AttributeName": "UserKey", | |
"AttributeType": "S" | |
}, | |
{ | |
"AttributeName": "CreatedAt", | |
"AttributeType": "N" | |
}, | |
{ | |
"AttributeName": "StatusAndCreation", | |
"AttributeType": "S" | |
} | |
], | |
"KeySchema": [ | |
{ | |
"AttributeName": "UserKey", | |
"KeyType": "HASH" | |
}, | |
{ | |
"AttributeName": "Protocol", | |
"KeyType": "RANGE" | |
} | |
], | |
"LocalSecondaryIndexes": [ | |
{ | |
"IndexName": "StatusAndCreationIndex", | |
"KeySchema": [ | |
{ | |
"AttributeName": "UserKey", | |
"KeyType": "HASH" | |
}, | |
{ | |
"AttributeName": "StatusAndCreation", | |
"KeyType": "RANGE" | |
} | |
], | |
"Projection": { | |
"ProjectionType": "KEYS_ONLY" | |
} | |
}, | |
{ | |
"IndexName": "CreationIndex", | |
"KeySchema": [ | |
{ | |
"AttributeName": "UserKey", | |
"KeyType": "HASH" | |
}, | |
{ | |
"AttributeName": "CreatedAt", | |
"KeyType": "RANGE" | |
} | |
], | |
"Projection": { | |
"ProjectionType": "KEYS_ONLY" | |
} | |
} | |
], | |
"ProvisionedThroughput": { | |
"ReadCapacityUnits": { | |
"Ref": "ThroughputDynamo" | |
}, | |
"WriteCapacityUnits": { | |
"Ref": "ThroughputDynamo" | |
} | |
} | |
} | |
}, | |
"ApplicationApplication": { | |
"Type": "AWS::ElasticBeanstalk::Application", | |
"Properties": { | |
"ApplicationName": "ApplicationAPIServer", | |
"Description": "Application application API" | |
} | |
}, | |
"ApplicationApplicationVersion": { | |
"Type": "AWS::ElasticBeanstalk::ApplicationVersion", | |
"Properties": { | |
"ApplicationName": { | |
"Ref": "ApplicationApplication" | |
}, | |
"SourceBundle": { | |
"S3Bucket": { | |
"Ref": "ApplicationBucket" | |
}, | |
"S3Key": "Application-0.0.1-SNAPSHOT.jar" | |
} | |
}, | |
"DependsOn": "ApplicationTable" | |
}, | |
"ApplicationBeanStalkConfigurationTemplate": { | |
"Type": "AWS::ElasticBeanstalk::ConfigurationTemplate", | |
"Properties": { | |
"ApplicationName": { | |
"Ref": "ApplicationApplication" | |
}, | |
"Description": "Application application Template", | |
"OptionSettings": [ | |
{ | |
"Namespace": "aws:autoscaling:asg", | |
"OptionName": "MinSize", | |
"Value": { | |
"Ref": "MinInstances" | |
} | |
}, | |
{ | |
"Namespace": "aws:autoscaling:asg", | |
"OptionName": "MaxSize", | |
"Value": { | |
"Ref": "MaxInstances" | |
} | |
}, | |
{ | |
"Namespace": "aws:elasticbeanstalk:environment", | |
"OptionName": "EnvironmentType", | |
"Value": "LoadBalanced" | |
}, | |
{ | |
"Namespace": "aws:elasticbeanstalk:application:environment", | |
"OptionName": "Application_KEY", | |
"Value": { | |
"Ref": "ApiKey" | |
} | |
}, | |
{ | |
"Namespace": "aws:elasticbeanstalk:application:environment", | |
"OptionName": "Application_DYNAMO", | |
"Value": { | |
"Fn::GetAtt": [ | |
"ApplicationTable", | |
"Arn" | |
] | |
} | |
}, | |
{ | |
"Namespace": "aws:elasticbeanstalk:application:environment", | |
"OptionName": "AMAZON_REGION", | |
"Value": { | |
"Ref": "AWSRegion" | |
} | |
}, | |
{ | |
"Namespace": "aws:elasticbeanstalk:application:environment", | |
"OptionName": "AMAZON_SECRET_KEY", | |
"Value": { | |
"Ref": "AWSSecretKey" | |
} | |
}, | |
{ | |
"Namespace": "aws:elasticbeanstalk:application:environment", | |
"OptionName": "AMAZON_ACCESS_KEY", | |
"Value": { | |
"Ref": "AWSAccessKey" | |
} | |
} | |
], | |
"SolutionStackName": "64bit Amazon Linux 2018.03 v2.7.4 running Java 8" | |
} | |
}, | |
"ApplicationBeanstalkEnvironment": { | |
"Type": "AWS::ElasticBeanstalk::Environment", | |
"Properties": { | |
"ApplicationName": { | |
"Ref": "ApplicationApplication" | |
}, | |
"EnvironmentName": "ApplicationEnvironment", | |
"TemplateName": { | |
"Ref": "ApplicationBeanStalkConfigurationTemplate" | |
}, | |
"VersionLabel": { | |
"Ref": "ApplicationApplicationVersion" | |
} | |
}, | |
"DependsOn": "ApplicationTable" | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment