-
Notifications
You must be signed in to change notification settings - Fork 0
/
elastic-beanstalk.yml
102 lines (94 loc) · 3.93 KB
/
elastic-beanstalk.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
AWSTemplateFormatVersion: "2010-09-09"
Parameters:
ApplicationExists:
Type: String
Description: "if false, a new application is created"
Default: "true"
AllowedValues:
- "true"
- "false"
ApplicationName:
Type: String
Description: "name of the application"
MinLength: 1
MaxLength: 100
ApplicationVersionS3Key:
Type: String
Description: "name of app version file in S3 bucket, e.g. as returned by `eb appversion --create`: temp/app-2e78-240701_194644561426.zip"
CertbotEmail:
Type: String
Description: "email address to use for certificate creation using certbot"
MinLength: 5
EnvironmentName:
Type: String
Description: "name of the environment (4-40 chars)"
MinLength: 4
MaxLength: 40
KeyName:
# use String instead of AWS::EC2::KeyPair::KeyName to allow empty values
Type: String
Description: "[optional] name of key pair to use for SSH access (must match existing key pair, if not empty)"
IamInstanceProfile:
Type: String
Default: "aws-elasticbeanstalk-ec2-role"
Description: "https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/iam-instanceprofile.html"
Conditions:
NewApplication: !Equals [!Ref ApplicationExists, "false"]
KeyNameSpecified: !Not [!Equals [!Ref KeyName, ""]]
Resources:
ApplicationVersion:
Type: AWS::ElasticBeanstalk::ApplicationVersion
Properties:
ApplicationName: !Ref ApplicationName
SourceBundle:
S3Bucket: !Sub elasticbeanstalk-${AWS::Region}-${AWS::AccountId}
S3Key: !Ref ApplicationVersionS3Key
ApplicationTemp:
# https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-elasticbeanstalk-application.html
Type: AWS::ElasticBeanstalk::Application
Condition: NewApplication
Properties:
ApplicationName: !Ref ApplicationName
Description: "Temporary application for testing single-instance HTTPS configuration"
EnvironmentTemp:
# https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-elasticbeanstalk-environment.html
Type: AWS::ElasticBeanstalk::Environment
Properties:
ApplicationName: !Ref ApplicationName
EnvironmentName: !Ref EnvironmentName
Description: "Temporary environment for testing single-instance HTTPS configuration"
TemplateName: !If [KeyNameSpecified, !Ref ConfigTemplateWithKey, !Ref ConfigTemplateWithoutKey]
VersionLabel: !Ref ApplicationVersion
ConfigTemplateWithoutKey:
# https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-elasticbeanstalk-configurationtemplate.html
Type: AWS::ElasticBeanstalk::ConfigurationTemplate
Properties:
ApplicationName: !Ref ApplicationName
# https://docs.aws.amazon.com/elasticbeanstalk/latest/platforms/platforms-supported.html#platforms-supported.python
SolutionStackName: "64bit Amazon Linux 2023 v4.1.0 running Python 3.11"
# https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/command-options-general.html
OptionSettings:
- Namespace: "aws:autoscaling:launchconfiguration"
OptionName: "IamInstanceProfile"
Value: !Ref IamInstanceProfile
- Namespace: "aws:ec2:instances"
OptionName: "InstanceTypes"
Value: "t4g.micro"
- Namespace: "aws:elasticbeanstalk:environment"
OptionName: "EnvironmentType"
Value: "SingleInstance"
- Namespace: "aws:elasticbeanstalk:application:environment"
OptionName: "CERTBOT_EMAIL"
Value: !Ref CertbotEmail
ConfigTemplateWithKey:
Type: AWS::ElasticBeanstalk::ConfigurationTemplate
Condition: KeyNameSpecified
Properties:
ApplicationName: !Ref ApplicationName
SourceConfiguration:
ApplicationName: !Ref ApplicationName
TemplateName: !Ref ConfigTemplateWithoutKey
OptionSettings:
- Namespace: "aws:autoscaling:launchconfiguration"
OptionName: "EC2KeyName"
Value: !Ref KeyName