Skip to content

Commit 0e9392a

Browse files
authored
Merge pull request caktus#92 from caktus/eks-with-nodegroup
EKS with nodegroup
2 parents 14f5866 + b717919 commit 0e9392a

18 files changed

+579
-414
lines changed

CHANGELOG.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,12 @@ Change Log
1919

2020
What's new in 2.0.0:
2121

22+
* Add support for Elastic Kubernetes Service (EKS).
2223
* Re-purpose use_aes256_encryption flag to support encryption across S3, RDS, Elasticache (Redis only), and RDS (thanks @dsummersl)
2324
* Add support for Customer Managed CMKs with ``CustomerManagedCmkArn`` parameter (not applied to public buckets)
2425
* Add configurable ContainerVolumeSize to change root volume size of EC2 instances (thanks @dsummersl)
2526
* Change generated template output from JSON to YAML (thanks @cchurch)
27+
* The stack no longer prompts for a ``SECRET_KEY`` if it won't be used for the stack type in question.
2628
* Add required DBParameterGroup by default, which allows configuring database specific parameters. This avoids having to reboot a production database instance to add a DBParameterGroup in the future. (thanks @cchurch)
2729
* Add tags to all resources, including a common ``aws-web-stacks:stack-name`` tag with the stack's name
2830
* Add a ``aws-web-stacks:role`` tag to EC2 instances to identify as bastion vs. worker.

Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ templates:
1212
USE_EB=on USE_NAT_GATEWAY=on python -c 'import stack' > content/eb-nat.yaml
1313
USE_ECS=on python -c 'import stack' > content/ecs-no-nat.yaml
1414
USE_ECS=on USE_NAT_GATEWAY=on python -c 'import stack' > content/ecs-nat.yaml
15+
USE_EKS=on python -c 'import stack' > content/eks-no-nat.yaml
16+
USE_EKS=on USE_NAT_GATEWAY=on python -c 'import stack' > content/eks-nat.yaml
1517
USE_DOKKU=on python -c 'import stack' > content/dokku-no-nat.yaml
1618
# USE_DOKKU=on USE_NAT_GATEWAY=on python -c 'import stack' > content/dokku-nat.yaml (disabled; need to SSH to instance to deploy)
1719
USE_GOVCLOUD=on python -c 'import stack' > content/gc-no-nat.yaml

README.rst

Lines changed: 32 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ AWS Web Stacks
55
:target: https://circleci.com/gh/caktus/aws-web-stacks
66

77
AWS Web Stacks is a library of CloudFormation templates that dramatically simplify hosting web applications
8-
on AWS. The library supports using Elastic Container Service (ECS), Elastic Beanstalk (EB), EC2 instances
9-
(via an AMI you specify), or `Dokku <http://dokku.viewdocs.io/dokku/>`_ for the application server(s) and
8+
on AWS. The library supports using Elastic Beanstalk, ECS, EKS, EC2 instances (via an AMI you specify),
9+
or `Dokku <http://dokku.viewdocs.io/dokku/>`_ for the application server(s) and
1010
provides auxilary managed services such as an RDS instance, ElastiCache instance, Elasticsearch instance
1111
(free) SSL certificate via AWS Certificate Manager, S3 bucket for static assets, ECS repository for hosting
1212
Docker images, etc. All resources (that support VPCs) are created in a self-contained VPC, which may use a
@@ -19,27 +19,27 @@ which allows for some validation at build time and simplifies the management of
1919
templates.
2020

2121
If a NAT gateway is not used, it's possible to create a fully-managed, self-contained hosting
22-
environment for your application entirely within the free tier on AWS. To try it out, select
23-
one of the following:
22+
environment for your application entirely within the free tier on AWS (albeit not with all stacks,
23+
for example, there is no free tier for EKS). To try it out, select one of the following:
2424

25-
+---------------------+-------------------+---------------------------+---------------+-----------------+
26-
| | Elastic Beanstalk | Elastic Container Service | EC2 Instances | Dokku |
27-
+=====================+===================+===========================+===============+=================+
28-
| Without NAT Gateway | |EB-No-NAT|_ | |ECS-No-NAT|_ | |EC2-No-NAT|_ | |Dokku-No-NAT|_ |
29-
+---------------------+-------------------+---------------------------+---------------+-----------------+
30-
| With NAT Gateway | |EB-NAT|_ | |ECS-NAT|_ | |EC2-NAT|_ | n/a |
31-
+---------------------+-------------------+---------------------------+---------------+-----------------+
25+
+---------------------+-------------------+---------------+---------------+---------------+-----------------+
26+
| | Elastic Beanstalk | ECS | EKS | EC2 Instances | Dokku |
27+
+=====================+===================+===============+===============+===============+=================+
28+
| Without NAT Gateway | |EB-No-NAT|_ | |ECS-No-NAT|_ | |EKS-No-NAT|_ | |EC2-No-NAT|_ | |Dokku-No-NAT|_ |
29+
+---------------------+-------------------+---------------+---------------+---------------+-----------------+
30+
| With NAT Gateway | |EB-NAT|_ | |ECS-NAT|_ | |EKS-NAT|_ | |EC2-NAT|_ | n/a |
31+
+---------------------+-------------------+---------------+---------------+---------------+-----------------+
3232

3333
If you'd like to review the CloudFormation template first, or update an existing stack, you may also
3434
wish to use the YAML template directly:
3535

36-
+---------------------+-------------------+---------------------------+--------------------+----------------------+
37-
| | Elastic Beanstalk | Elastic Container Service | EC2 Instances | Dokku |
38-
+=====================+===================+===========================+====================+======================+
39-
| Without NAT Gateway | `eb-no-nat.yaml`_ | `ecs-no-nat.yaml`_ | `ec2-no-nat.yaml`_ | `dokku-no-nat.yaml`_ |
40-
+---------------------+-------------------+---------------------------+--------------------+----------------------+
41-
| With NAT Gateway | `eb-nat.yaml`_ | `ecs-nat.yaml`_ | `ec2-nat.yaml`_ | n/a |
42-
+---------------------+-------------------+---------------------------+--------------------+----------------------+
36+
+---------------------+-------------------+--------------------+--------------------+--------------------+----------------------+
37+
| | Elastic Beanstalk | ECS | EKS | EC2 Instances | Dokku |
38+
+=====================+===================+====================+====================+====================+======================+
39+
| Without NAT Gateway | `eb-no-nat.yaml`_ | `ecs-no-nat.yaml`_ | `eks-no-nat.yaml`_ | `ec2-no-nat.yaml`_ | `dokku-no-nat.yaml`_ |
40+
+---------------------+-------------------+--------------------+--------------------+--------------------+----------------------+
41+
| With NAT Gateway | `eb-nat.yaml`_ | `ecs-nat.yaml`_ | `eks-nat.yaml`_ | `ec2-nat.yaml`_ | n/a |
42+
+---------------------+-------------------+--------------------+--------------------+--------------------+----------------------+
4343

4444
.. |EB-No-NAT| image:: https://s3.amazonaws.com/cloudformation-examples/cloudformation-launch-stack.png
4545
.. _EB-No-NAT: https://console.aws.amazon.com/cloudformation/home?#/stacks/new?stackName=eb-app-no-nat&templateURL=https://s3.amazonaws.com/aws-web-stacks/eb-no-nat.yaml
@@ -57,6 +57,14 @@ wish to use the YAML template directly:
5757
.. _ECS-NAT: https://console.aws.amazon.com/cloudformation/home?#/stacks/new?stackName=ecs-app-with-nat&templateURL=https://s3.amazonaws.com/aws-web-stacks/ecs-nat.yaml
5858
.. _ecs-nat.yaml: https://s3.amazonaws.com/aws-web-stacks/ecs-nat.yaml
5959

60+
.. |EKS-No-NAT| image:: https://s3.amazonaws.com/cloudformation-examples/cloudformation-launch-stack.png
61+
.. _EKS-No-NAT: https://console.aws.amazon.com/cloudformation/home?#/stacks/new?stackName=eks-no-nat&templateURL=https://s3.amazonaws.com/aws-web-stacks/eks-no-nat.yaml
62+
.. _eks-no-nat.yaml: https://s3.amazonaws.com/aws-web-stacks/eks-no-nat.yaml
63+
64+
.. |EKS-NAT| image:: https://s3.amazonaws.com/cloudformation-examples/cloudformation-launch-stack.png
65+
.. _EKS-NAT: https://console.aws.amazon.com/cloudformation/home?#/stacks/new?stackName=eks-with-nat&templateURL=https://s3.amazonaws.com/aws-web-stacks/eks-nat.yaml
66+
.. _eks-nat.yaml: https://s3.amazonaws.com/aws-web-stacks/eks-nat.yaml
67+
6068
.. |EC2-No-NAT| image:: https://s3.amazonaws.com/cloudformation-examples/cloudformation-launch-stack.png
6169
.. _EC2-No-NAT: https://console.aws.amazon.com/cloudformation/home?#/stacks/new?stackName=ec2-app-no-nat&templateURL=https://s3.amazonaws.com/aws-web-stacks/ec2-no-nat.yaml
6270
.. _ec2-no-nat.yaml: https://s3.amazonaws.com/aws-web-stacks/ec2-no-nat.yaml
@@ -76,8 +84,8 @@ In addition to this README, there is additional documentation at
7684
http://aws-web-stacks.readthedocs.io/
7785

7886

79-
Elastic Beanstalk, Elastic Container Service, EC2, or Dokku?
80-
------------------------------------------------------------
87+
Elastic Beanstalk, Elastic Container Service, EC2, Dokku, or EKS?
88+
-----------------------------------------------------------------
8189

8290
**Elastic Beanstalk** is the recommended starting point. Elastic Beanstalk comes with a preconfigured
8391
autoscaling configuration, allows for automated, managed updates to the underlying servers, allows changing
@@ -86,7 +94,8 @@ tool for managing deployments. The Elastic Beanstalk environment uses the
8694
`multicontainer docker environment <http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/create_deploy_docker_ecs.html>`_
8795
to maximize flexibility in terms of the application(s) and container(s) deployed to the stack.
8896

89-
**Elastic Container Service (ECS)** might be useful if complex container service definitions are required.
97+
**Elastic Container Service (ECS)** or **Elastic Kubernetes Service (EKS)** might be useful if complex container
98+
service definitions are required.
9099

91100
If you prefer to configure application servers manually using Ansible, Salt, Chef, Puppet, or another such tool,
92101
choose the **EC2** option. Be aware that the instances created are managed by an autoscaling group, so you should
@@ -499,6 +508,8 @@ USE_EB=on
499508
Create an Elastic Beanstalk application
500509
USE_ECS=on
501510
Create an Elastic Container Service.
511+
USE_EKS=on
512+
Create an AWS EKS (Kubernetes) cluster.
502513
USE_DOKKU=on
503514
Create an EC2 instance containing a Dokku server
504515

stack/__init__.py

Lines changed: 38 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,47 @@
11
import datetime
22
import os
33

4-
from . import sftp # noqa: F401
5-
from . import assets # noqa: F401
6-
from . import cache # noqa: F401
7-
from . import database # noqa: F401
8-
from . import logs # noqa: F401
9-
from . import vpc # noqa: F401
10-
from . import template
4+
USE_DOKKU = os.environ.get("USE_DOKKU") == "on"
5+
USE_EB = os.environ.get("USE_EB") == "on"
6+
USE_EC2 = os.environ.get("USE_EC2") == "on"
7+
USE_ECS = os.environ.get("USE_ECS") == "on"
8+
USE_EKS = os.environ.get("USE_EKS") == "on"
9+
USE_GOVCLOUD = os.environ.get("USE_GOVCLOUD") == "on"
10+
USE_NAT_GATEWAY = os.environ.get("USE_NAT_GATEWAY") == "on"
1111

12-
if os.environ.get('USE_GOVCLOUD') != 'on':
13-
# make sure this isn't added to the template for GovCloud, as it's not
14-
# supported in this region
15-
from . import search # noqa: F401
12+
if USE_EKS:
13+
from . import vpc # noqa: F401
14+
from . import template
15+
from . import repository # noqa: F401
16+
from . import eks # noqa: F401
17+
else:
18+
from . import sftp # noqa: F401
19+
from . import assets # noqa: F401
20+
from . import cache # noqa: F401
21+
from . import database # noqa: F401
22+
from . import logs # noqa: F401
23+
from . import vpc # noqa: F401
24+
from . import template
1625

17-
if os.environ.get('USE_NAT_GATEWAY') == 'on':
18-
from . import bastion # noqa: F401
26+
if not USE_GOVCLOUD:
27+
# make sure this isn't added to the template for GovCloud, as it's not
28+
# supported in this region
29+
from . import search # noqa: F401
1930

20-
if os.environ.get('USE_ECS') == 'on':
21-
from . import repository # noqa: F401
22-
from . import cluster # noqa: F401
23-
elif os.environ.get('USE_EB') == 'on':
24-
from . import repository # noqa: F401
25-
from . import eb # noqa: F401
26-
elif os.environ.get('USE_DOKKU') == 'on':
27-
from . import dokku # noqa: F401
28-
else: # USE_GOVCLOUD and USE_EC2 both provide EC2 instances
29-
from . import instances # noqa: F401
31+
if USE_NAT_GATEWAY:
32+
from . import bastion # noqa: F401
33+
34+
if USE_ECS:
35+
from . import repository # noqa: F401
36+
from . import ecs_cluster # noqa: F401
37+
elif USE_EB:
38+
from . import repository # noqa: F401
39+
from . import eb # noqa: F401
40+
elif USE_DOKKU:
41+
from . import dokku # noqa: F401
42+
elif USE_EC2 or USE_GOVCLOUD:
43+
# USE_GOVCLOUD and USE_EC2 both provide EC2 instances
44+
from . import instances # noqa: F401
3045

3146
# Must be last to tag all resources
3247
from . import tags # noqa: F401

stack/assets.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import os
2-
31
from troposphere import (
42
AWS_REGION,
53
And,
@@ -36,6 +34,7 @@
3634
VersioningConfiguration
3735
)
3836

37+
from . import USE_GOVCLOUD
3938
from .common import (
4039
arn_prefix,
4140
cmk_arn,
@@ -263,7 +262,7 @@
263262
)
264263

265264

266-
if os.environ.get('USE_GOVCLOUD') != 'on':
265+
if not USE_GOVCLOUD:
267266
assets_use_cloudfront = template.add_parameter(
268267
Parameter(
269268
"AssetsUseCloudFront",

stack/common.py

Lines changed: 12 additions & 117 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from troposphere import AWS_REGION, Equals, If, Not, Ref
22

3+
from . import USE_DOKKU, USE_EB, USE_EC2, USE_ECS, USE_GOVCLOUD
34
from .template import template
45
from .utils import ParameterWithDefaults as Parameter
56

@@ -22,123 +23,17 @@
2223
label="Admin IP Address",
2324
))
2425

25-
container_instance_type = Ref(template.add_parameter(
26-
Parameter(
27-
"ContainerInstanceType",
28-
Description="The application server instance type",
29-
Type="String",
30-
Default="t2.micro",
31-
AllowedValues=[
32-
't3.nano',
33-
't3.micro',
34-
't3.small',
35-
't3.medium',
36-
't3.large',
37-
't3.xlarge',
38-
't3.2xlarge',
39-
't2.nano',
40-
't2.micro',
41-
't2.small',
42-
't2.medium',
43-
't2.large',
44-
't2.xlarge',
45-
't2.2xlarge',
46-
'm5.large',
47-
'm5.xlarge',
48-
'm5.2xlarge',
49-
'm5.4xlarge',
50-
'm5.12xlarge',
51-
'm5.24xlarge',
52-
'm5d.large',
53-
'm5d.xlarge',
54-
'm5d.2xlarge',
55-
'm5d.4xlarge',
56-
'm5d.12xlarge',
57-
'm5d.24xlarge',
58-
'm4.large',
59-
'm4.xlarge',
60-
'm4.2xlarge',
61-
'm4.4xlarge',
62-
'm4.10xlarge',
63-
'm4.16xlarge',
64-
'm3.medium',
65-
'm3.large',
66-
'm3.xlarge',
67-
'm3.2xlarge',
68-
'c5.large',
69-
'c5.xlarge',
70-
'c5.2xlarge',
71-
'c5.4xlarge',
72-
'c5.9xlarge',
73-
'c5.18xlarge',
74-
'c5d.large',
75-
'c5d.xlarge',
76-
'c5d.2xlarge',
77-
'c5d.4xlarge',
78-
'c5d.9xlarge',
79-
'c5d.18xlarge',
80-
'c4.large',
81-
'c4.xlarge',
82-
'c4.2xlarge',
83-
'c4.4xlarge',
84-
'c4.8xlarge',
85-
'c3.large',
86-
'c3.xlarge',
87-
'c3.2xlarge',
88-
'c3.4xlarge',
89-
'c3.8xlarge',
90-
'p2.xlarge',
91-
'p2.8xlarge',
92-
'p2.16xlarge',
93-
'g2.2xlarge',
94-
'g2.8xlarge',
95-
'x1.16large',
96-
'x1.32xlarge',
97-
'r5.large',
98-
'r5.xlarge',
99-
'r5.2xlarge',
100-
'r5.4xlarge',
101-
'r5.12xlarge',
102-
'r5.24xlarge',
103-
'r4.large',
104-
'r4.xlarge',
105-
'r4.2xlarge',
106-
'r4.4xlarge',
107-
'r4.8xlarge',
108-
'r4.16xlarge',
109-
'r3.large',
110-
'r3.xlarge',
111-
'r3.2xlarge',
112-
'r3.4xlarge',
113-
'r3.8xlarge',
114-
'i3.large',
115-
'i3.xlarge',
116-
'i3.2xlarge',
117-
'i3.4xlarge',
118-
'i3.8xlarge',
119-
'i3.16large',
120-
'd2.xlarge',
121-
'd2.2xlarge',
122-
'd2.4xlarge',
123-
'd2.8xlarge',
124-
'f1.2xlarge',
125-
'f1.16xlarge',
126-
]
127-
),
128-
group="Application Server",
129-
label="Instance Type",
130-
))
131-
132-
secret_key = Ref(template.add_parameter(
133-
Parameter(
134-
"SecretKey",
135-
Description="Application secret key for this stack (optional)",
136-
Type="String",
137-
NoEcho=True,
138-
),
139-
group="Application Server",
140-
label="Secret Key",
141-
))
26+
if any([USE_DOKKU, USE_EB, USE_ECS, USE_EC2, USE_GOVCLOUD]):
27+
secret_key = Ref(template.add_parameter(
28+
Parameter(
29+
"SecretKey",
30+
Description="Application secret key for this stack (optional)",
31+
Type="String",
32+
NoEcho=True,
33+
),
34+
group="Application Server",
35+
label="Secret Key",
36+
))
14237

14338
use_aes256_encryption = Ref(template.add_parameter(
14439
Parameter(

0 commit comments

Comments
 (0)