Skip to content

Commit e3e3599

Browse files
authored
Merge pull request caktus#96 from caktus/add-services-to-eks
Optionally create services with EKS
2 parents ebab460 + e886b5b commit e3e3599

File tree

5 files changed

+52
-41
lines changed

5 files changed

+52
-41
lines changed

CHANGELOG.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ Change Log
55
`X.Y.Z`_ (TBD-DD-DD)
66
---------------------
77

8+
* Optionally create RDS, Redis, memcached, elasticsearch services when creating
9+
an EKS cluster.
810
* TBD
911

1012

stack/__init__.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,17 @@
1414
from . import template
1515
from . import repository # noqa: F401
1616
from . import eks # noqa: F401
17+
from . import cache # noqa: F401
18+
from . import database # noqa: F401
19+
from . import logs # noqa: F401
20+
if not USE_GOVCLOUD:
21+
# make sure this isn't added to the template for GovCloud, as it's not
22+
# supported in this region
23+
from . import search # noqa: F401
24+
25+
if USE_NAT_GATEWAY:
26+
from . import bastion # noqa: F401
27+
1728
else:
1829
from . import sftp # noqa: F401
1930
from . import assets # noqa: F401
@@ -51,8 +62,8 @@
5162
print("# https://github.com/caktus/aws-web-stacks")
5263
print("# at %s" % datetime.datetime.now())
5364
print("# with parameters:")
54-
use_parms = sorted(parm for parm in os.environ.keys() if parm.startswith("USE_"))
55-
for parm in use_parms:
65+
parms_used = sorted(parm for parm in os.environ.keys() if parm.startswith("USE_") or parm == "DEFAULTS_FILE")
66+
for parm in parms_used:
5667
print("#\t%s = %s" % (parm, os.environ[parm]))
5768
print()
5869
print(template.template.to_yaml())

stack/eks.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@
9393
[
9494
Output(
9595
"ClusterEndpoint",
96-
Description="The connection endpoint for the cluster API.",
96+
Description="The connection endpoint for the EKS cluster API.",
9797
Value=GetAtt(cluster, "Endpoint"),
9898
),
9999
]

stack/repository.py

Lines changed: 25 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,6 @@
11
import awacs.ecr as ecr
22
from awacs.aws import Allow, AWSPrincipal, Policy, Statement
3-
from troposphere import (
4-
AWS_ACCOUNT_ID,
5-
AWS_REGION,
6-
AWS_STACK_NAME,
7-
Join,
8-
Output,
9-
Ref
10-
)
3+
from troposphere import AWS_ACCOUNT_ID, AWS_REGION, Join, Output, Ref
114
from troposphere.ecr import Repository
125

136
from .common import arn_prefix
@@ -17,22 +10,20 @@
1710
repository = Repository(
1811
"ApplicationRepository",
1912
template=template,
20-
RepositoryName=Ref(AWS_STACK_NAME),
13+
# Do we need to specify a repository name? The stack name might not be
14+
# a valid repository name, and if we just leave it out, AWS will make one
15+
# up for us.
16+
# RepositoryName=Ref(AWS_STACK_NAME),
2117
# Allow all account users to manage images.
2218
RepositoryPolicyText=Policy(
2319
Version="2008-10-17",
2420
Statement=[
2521
Statement(
2622
Sid="AllowPushPull",
2723
Effect=Allow,
28-
Principal=AWSPrincipal([
29-
Join("", [
30-
arn_prefix,
31-
":iam::",
32-
Ref(AWS_ACCOUNT_ID),
33-
":root",
34-
]),
35-
]),
24+
Principal=AWSPrincipal(
25+
[Join("", [arn_prefix, ":iam::", Ref(AWS_ACCOUNT_ID), ":root"])]
26+
),
3627
Action=[
3728
ecr.GetDownloadUrlForLayer,
3829
ecr.BatchGetImage,
@@ -43,20 +34,25 @@
4334
ecr.CompleteLayerUpload,
4435
],
4536
),
46-
]
37+
],
4738
),
4839
)
4940

5041

5142
# Output ECR repository URL
52-
template.add_output(Output(
53-
"RepositoryURL",
54-
Description="The docker repository URL",
55-
Value=Join("", [
56-
Ref(AWS_ACCOUNT_ID),
57-
".dkr.ecr.",
58-
Ref(AWS_REGION),
59-
".amazonaws.com/",
60-
Ref(repository),
61-
]),
62-
))
43+
template.add_output(
44+
Output(
45+
"RepositoryURL",
46+
Description="The docker repository URL",
47+
Value=Join(
48+
"",
49+
[
50+
Ref(AWS_ACCOUNT_ID),
51+
".dkr.ecr.",
52+
Ref(AWS_REGION),
53+
".amazonaws.com/",
54+
Ref(repository),
55+
],
56+
),
57+
)
58+
)

stack/security_groups.py

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -59,15 +59,17 @@
5959
SourceSecurityGroupId=Ref(load_balancer_security_group),
6060
))
6161

62-
if not USE_NAT_GATEWAY:
63-
# Allow direct administrator access via SSH.
64-
ingress_rules.append(SecurityGroupRule(
65-
IpProtocol="tcp",
66-
FromPort="22",
67-
ToPort="22",
68-
Description="Administrator SSH Access",
69-
CidrIp=administrator_ip_address,
70-
))
62+
if not USE_NAT_GATEWAY:
63+
# Allow direct administrator access via SSH.
64+
ingress_rules.append(SecurityGroupRule(
65+
IpProtocol="tcp",
66+
FromPort="22",
67+
ToPort="22",
68+
Description="Administrator SSH Access",
69+
CidrIp=administrator_ip_address,
70+
))
71+
else:
72+
ingress_rules = []
7173

7274
container_security_group = SecurityGroup(
7375
# NOTE: If creating an EKS cluster, eks.py will modify this security group.

0 commit comments

Comments
 (0)