Last active
March 4, 2019 17:52
-
-
Save kevinmmartins/71aed4d1ec463f49a6dd8e6611047a15 to your computer and use it in GitHub Desktop.
Cloudformation with Beanstalk and CloudFront
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", | |
"Metadata":{ | |
"AWS::CloudFormation::Interface":{ | |
"ParameterGroups":[ | |
{ | |
"Label":{ | |
"default":"Application version" | |
}, | |
"Parameters":[ | |
"ApplicationBucket", | |
"ApplicationArtifact", | |
"MaxInstances", | |
"MinInstances" | |
] | |
}, | |
{ | |
"Label":{ | |
"default":"KeyStore" | |
}, | |
"Parameters":[ | |
"KeyStoreName", | |
"KeyStorePassword" | |
] | |
}, | |
{ | |
"Label":{ | |
"default":"Application configuration" | |
}, | |
"Parameters":[ | |
"SPDNS", | |
"IDPHost", | |
"IDPMetadataPath", | |
"AppSSLCheck" | |
] | |
} | |
] | |
} | |
}, | |
"Parameters":{ | |
"ApplicationBucket":{ | |
"Type":"String", | |
"Description":"The bucket name with Application artifact", | |
"Default":"Application-deploy" | |
}, | |
"SPDNS":{ | |
"Type":"String", | |
"Description":"DNS Service Provider" | |
}, | |
"IDPHost":{ | |
"Type":"String", | |
"Description":"ADFS host name" | |
}, | |
"IDPMetadataPath":{ | |
"Type":"String", | |
"Description":"ADFS Federation Metadata to establish a Relying Party Trust", | |
"Default":"/FederationMetadata/2007-06/FederationMetadata.xml" | |
}, | |
"KeyStoreName":{ | |
"Type":"String", | |
"Description":"File Name", | |
"Default":"samlKeystore" | |
}, | |
"KeyStorePassword":{ | |
"NoEcho":"true", | |
"Type":"String", | |
"Description":"Password for protect the file" | |
}, | |
"AppSSLCheck":{ | |
"AllowedValues":[ | |
"true", | |
"false" | |
], | |
"Default":"false", | |
"Type":"String", | |
"Description":"When TRUE indicate for Java to trust in certificate they are receiving" | |
}, | |
"MinInstances":{ | |
"Type":"Number", | |
"Default":"1", | |
"Description":"The min value of Application instances" | |
}, | |
"MaxInstances":{ | |
"Type":"Number", | |
"Default":"1", | |
"Description":"The max value of Application instances" | |
}, | |
"ApplicationArtifact":{ | |
"Type":"String", | |
"Default":"Application-1.0.0.jar", | |
"Description":"The application authentication Artifact name" | |
} | |
}, | |
"Outputs":{ | |
"AccidentApiUrl":{ | |
"Description":"URL of application Authentication API load balancer", | |
"Value":{ | |
"Fn::GetAtt":[ | |
"ApplicationBeanstalkEnvironment", | |
"EndpointURL" | |
] | |
} | |
}, | |
"CloudfrontEndpoint":{ | |
"Value":{ | |
"Fn::GetAtt":[ | |
"ApplicationCloudFront", | |
"DomainName" | |
] | |
}, | |
"Description":"Endpoint for Cloudfront distribution" | |
} | |
}, | |
"Resources":{ | |
"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":{ | |
"Ref":"ApplicationArtifact" | |
} | |
} | |
} | |
}, | |
"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":"BB_SP_DNS", | |
"Value":{ | |
"Ref":"SPDNS" | |
} | |
}, | |
{ | |
"Namespace":"aws:elasticbeanstalk:application:environment", | |
"OptionName":"BB_IDP_HOST", | |
"Value":{ | |
"Ref":"IDPHost" | |
} | |
}, | |
{ | |
"Namespace":"aws:elasticbeanstalk:application:environment", | |
"OptionName":"BB_IDP_METADATA_FEDERATION_PATH", | |
"Value":{ | |
"Ref":"IDPMetadataPath" | |
} | |
}, | |
{ | |
"Namespace":"aws:elasticbeanstalk:application:environment", | |
"OptionName":"BB_KEYSTORE_NAME", | |
"Value":{ | |
"Ref":"KeyStoreName" | |
} | |
}, | |
{ | |
"Namespace":"aws:elasticbeanstalk:application:environment", | |
"OptionName":"BB_KEYSTORE_PASS", | |
"Value":{ | |
"Ref":"KeyStorePassword" | |
} | |
}, | |
{ | |
"Namespace":"aws:elasticbeanstalk:application:environment", | |
"OptionName":"BB_APP_SSL_CHECK", | |
"Value":{ | |
"Ref":"AppSSLCheck" | |
} | |
} | |
], | |
"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" | |
} | |
} | |
}, | |
"ApplicationCloudFront":{ | |
"Type":"AWS::CloudFront::Distribution", | |
"DependsOn":"ApplicationBeanstalkEnvironment", | |
"Properties":{ | |
"DistributionConfig":{ | |
"Origins":[ | |
{ | |
"DomainName":{ | |
"Fn::GetAtt":[ | |
"ApplicationBeanstalkEnvironment", | |
"EndpointURL" | |
] | |
}, | |
"Id":"ApplicationHTTPS", | |
"CustomOriginConfig":{ | |
"HTTPPort":"80", | |
"HTTPSPort":"443", | |
"OriginProtocolPolicy":"http-only" | |
} | |
} | |
], | |
"Enabled":"true", | |
"Comment":"The application Authentication", | |
"DefaultCacheBehavior":{ | |
"AllowedMethods":[ | |
"DELETE", | |
"GET", | |
"HEAD", | |
"OPTIONS", | |
"PATCH", | |
"POST", | |
"PUT" | |
], | |
"TargetOriginId":"ApplicationHTTPS", | |
"ViewerProtocolPolicy":"redirect-to-https", | |
"ForwardedValues":{ | |
"Headers":[ | |
"Host" | |
], | |
"QueryString":"false", | |
"Cookies":{ | |
"Forward":"none" | |
} | |
} | |
}, | |
"PriceClass":"PriceClass_All", | |
"ViewerCertificate":{ | |
"CloudFrontDefaultCertificate":"true" | |
} | |
} | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment