Last active
November 2, 2016 02:19
-
-
Save shicholas/0b198c4fc27499804689f2013daca61a to your computer and use it in GitHub Desktop.
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' | |
Description: > | |
This template a ruby elasticbeanstalk environment that connects to a | |
postgresql database by allowing for traffic within the databases\'s vpc | |
Parameters: | |
ApplicationName: | |
Description: Name of Elasticbeanstalk application | |
Type: String | |
KeyName: | |
Description: > | |
Name of EC2 Key Pair to ssh into instances | |
https://us-east-2.console.aws.amazon.com/ec2/v2/home?region=us-east-2#KeyPairs:sort=keyName | |
Type: String | |
RoutingStackName: | |
Description: Stack name of cloudformation stack ran with the routing template | |
Type: String | |
Default: initial-routing | |
VPCStackName: | |
Description: Cloudformation stack name that was ran with the vpc template | |
Type: String | |
Default: staging-vpc | |
Resources: | |
ElasticbeanstalkRole: | |
Type: AWS::IAM::Role | |
Properties: | |
RoleName: rails-api-staging | |
AssumeRolePolicyDocument: | |
Statement: | |
- Effect: Allow | |
Principal: | |
Service: | |
- ec2.amazonaws.com | |
Action: | |
- sts:AssumeRole | |
ManagedPolicyArns: | |
- arn:aws:iam::aws:policy/AWSElasticBeanstalkFullAccess | |
IAMInstanceProfile: | |
Type: AWS::IAM::InstanceProfile | |
Properties: | |
Path: '/' | |
Roles: | |
- !Ref ElasticbeanstalkRole | |
ElasticIp: | |
Type: AWS::EC2::EIP | |
Properties: | |
Domain: vpc | |
NATGateway: | |
Type: AWS::EC2::NatGateway | |
Properties: | |
AllocationId: !GetAtt ElasticIp.AllocationId | |
SubnetId: | |
Fn::ImportValue: !Sub "${VPCStackName}-PublicSubnet1" | |
PrivateRoute: | |
Type: AWS::EC2::Route | |
Properties: | |
RouteTableId: | |
Fn::ImportValue: !Sub "${VPCStackName}-PrivateRouteTable" | |
DestinationCidrBlock: 0.0.0.0/0 | |
NatGatewayId: !Ref NATGateway | |
EBApplication: | |
DependsOn: | |
- PrivateRoute | |
Type: AWS::ElasticBeanstalk::Application | |
Properties: | |
ApplicationName: !Ref ApplicationName | |
Description: rails-api | |
EBEnvironment: | |
DependsOn: | |
- EBApplication | |
Type: AWS::ElasticBeanstalk::Environment | |
Properties: | |
ApplicationName: !Ref ApplicationName | |
SolutionStackName: 64bit Amazon Linux 2016.09 v2.2.0 running Ruby 2.3 (Puma) | |
EnvironmentName: staging | |
OptionSettings: | |
- Namespace: aws:ec2:vpc | |
OptionName: VPCId | |
Value: | |
Fn::ImportValue: !Sub "${VPCStackName}-VpcId" | |
- Namespace: aws:ec2:vpc | |
OptionName: ELBSubnets | |
Value: | |
Fn::ImportValue: !Sub "${VPCStackName}-PublicSubnet1" | |
- Namespace: aws:elb:loadbalancer | |
OptionName: LoadBalancerHTTPSPort | |
Value: 443 | |
- Namespace: aws:autoscaling:asg | |
OptionName: MinSize | |
Value: 1 | |
- Namespace: aws:autoscaling:asg | |
OptionName: MaxSize | |
Value: 2 | |
- Namespace: aws:ec2:vpc | |
OptionName: Subnets | |
Value: | |
Fn::ImportValue: !Sub "${VPCStackName}-PrivateSubnet1" | |
- Namespace: aws:elasticbeanstalk:application | |
OptionName: Application Healthcheck Url | |
Value: /health | |
- Namespace: aws:elb:listener | |
OptionName: ListenerProtocol | |
Value: HTTPS | |
- Namespace: aws:autoscaling:launchconfiguration | |
OptionName: IamInstanceProfile | |
Value: !GetAtt IAMInstanceProfile.Arn | |
- Namespace: aws:elasticbeanstalk:environment | |
OptionName: ServiceRole | |
Value: rails-api-staging | |
- Namespace: aws:autoscaling:launchconfiguration | |
OptionName: EC2KeyName | |
Value: !Ref KeyName | |
- Namespace: aws:elb:listener | |
OptionName: SSLCertificateId | |
Value: | |
Fn::ImportValue: !Sub ${RoutingStackName}-SSLCertificate | |
Tier: | |
Name: WebServer | |
Type: Standard | |
Outputs: | |
EBUrl: | |
Description: URL of Elasticbeanstalk | |
Value: !GetAtt EBEnvironment.EndpointURL | |
Export: | |
Name: !Sub ${AWS::StackName}-ElasticbeanstalkUrl |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment