|
4 | 4 | from awacs import ecr
|
5 | 5 | from troposphere import Ref, iam
|
6 | 6 |
|
7 |
| -from stack import USE_ECS, USE_EKS |
| 7 | +from stack import USE_ECS, USE_EKS, USE_DOKKU, USE_EB |
8 | 8 | from stack.template import template
|
9 | 9 | from stack.utils import ParameterWithDefaults as Parameter
|
10 | 10 |
|
11 | 11 | if not USE_EKS:
|
12 | 12 | from stack.assets import assets_management_policy
|
13 | 13 | from stack.logs import logging_policy
|
14 | 14 |
|
15 |
| -desired_container_instances = Ref( |
16 |
| - template.add_parameter( |
17 |
| - Parameter( |
18 |
| - "DesiredScale", |
19 |
| - Description="Desired container instances count", |
20 |
| - Type="Number", |
21 |
| - Default="3" if USE_ECS else "2", |
22 |
| - ), |
23 |
| - group="Application Server", |
24 |
| - label="Desired Instance Count", |
| 15 | +if not USE_DOKKU and not USE_EB: |
| 16 | + desired_container_instances = Ref( |
| 17 | + template.add_parameter( |
| 18 | + Parameter( |
| 19 | + "DesiredScale", |
| 20 | + Description="Desired container instances count", |
| 21 | + Type="Number", |
| 22 | + Default="3" if USE_ECS else "2", |
| 23 | + ), |
| 24 | + group="Application Server", |
| 25 | + label="Desired Instance Count", |
| 26 | + ) |
25 | 27 | )
|
26 |
| -) |
27 |
| -max_container_instances = Ref( |
28 |
| - template.add_parameter( |
29 |
| - Parameter( |
30 |
| - "MaxScale", |
31 |
| - Description="Maximum container instances count", |
32 |
| - Type="Number", |
33 |
| - Default="3" if USE_ECS else "4", |
34 |
| - ), |
35 |
| - group="Application Server", |
36 |
| - label="Maximum Instance Count", |
| 28 | + max_container_instances = Ref( |
| 29 | + template.add_parameter( |
| 30 | + Parameter( |
| 31 | + "MaxScale", |
| 32 | + Description="Maximum container instances count", |
| 33 | + Type="Number", |
| 34 | + Default="3" if USE_ECS else "4", |
| 35 | + ), |
| 36 | + group="Application Server", |
| 37 | + label="Maximum Instance Count", |
| 38 | + ) |
37 | 39 | )
|
38 |
| -) |
39 | 40 |
|
40 |
| -container_volume_size = Ref( |
41 |
| - template.add_parameter( |
42 |
| - Parameter( |
43 |
| - "ContainerVolumeSize", |
44 |
| - Description="Size of instance EBS root volume (in GB)", |
45 |
| - Type="Number", |
46 |
| - Default="20" if USE_EKS else "8", |
47 |
| - ), |
48 |
| - group="Application Server", |
49 |
| - label="Root Volume Size", |
50 |
| - ) |
51 |
| -) |
| 41 | + if not USE_ECS: |
| 42 | + container_volume_size = Ref( |
| 43 | + template.add_parameter( |
| 44 | + Parameter( |
| 45 | + "ContainerVolumeSize", |
| 46 | + Description="Size of instance EBS root volume (in GB)", |
| 47 | + Type="Number", |
| 48 | + Default="20" if USE_EKS else "8", |
| 49 | + ), |
| 50 | + group="Application Server", |
| 51 | + label="Root Volume Size", |
| 52 | + ) |
| 53 | + ) |
52 | 54 |
|
53 | 55 | if USE_EKS:
|
54 | 56 | container_policies = []
|
|
89 | 91 | ]
|
90 | 92 | )
|
91 | 93 |
|
92 |
| -container_instance_role = iam.Role( |
93 |
| - "ContainerInstanceRole", |
94 |
| - template=template, |
95 |
| - AssumeRolePolicyDocument=dict( |
96 |
| - Statement=[ |
| 94 | +if not USE_EB: |
| 95 | + container_instance_role = iam.Role( |
| 96 | + "ContainerInstanceRole", |
| 97 | + template=template, |
| 98 | + AssumeRolePolicyDocument=dict( |
| 99 | + Statement=[ |
| 100 | + dict( |
| 101 | + Effect="Allow", |
| 102 | + Principal=dict(Service=["ec2.amazonaws.com"]), |
| 103 | + Action=["sts:AssumeRole"], |
| 104 | + ) |
| 105 | + ] |
| 106 | + ), |
| 107 | + Path="/", |
| 108 | + Policies=container_policies, |
| 109 | + **( |
97 | 110 | dict(
|
98 |
| - Effect="Allow", |
99 |
| - Principal=dict(Service=["ec2.amazonaws.com"]), |
100 |
| - Action=["sts:AssumeRole"], |
| 111 | + ManagedPolicyArns=[ |
| 112 | + "arn:aws:iam::aws:policy/AmazonEKSWorkerNodePolicy", |
| 113 | + "arn:aws:iam::aws:policy/AmazonEC2ContainerRegistryReadOnly", |
| 114 | + "arn:aws:iam::aws:policy/AmazonEKS_CNI_Policy", |
| 115 | + ] |
101 | 116 | )
|
102 |
| - ] |
103 |
| - ), |
104 |
| - Path="/", |
105 |
| - Policies=container_policies, |
106 |
| - **( |
107 |
| - dict( |
108 |
| - ManagedPolicyArns=[ |
109 |
| - "arn:aws:iam::aws:policy/AmazonEKSWorkerNodePolicy", |
110 |
| - "arn:aws:iam::aws:policy/AmazonEC2ContainerRegistryReadOnly", |
111 |
| - "arn:aws:iam::aws:policy/AmazonEKS_CNI_Policy", |
112 |
| - ] |
113 |
| - ) |
114 |
| - if USE_EKS |
115 |
| - else {} |
116 |
| - ), |
117 |
| -) |
| 117 | + if USE_EKS |
| 118 | + else {} |
| 119 | + ), |
| 120 | + ) |
118 | 121 |
|
119 |
| -container_instance_profile = iam.InstanceProfile( |
120 |
| - "ContainerInstanceProfile", |
121 |
| - template=template, |
122 |
| - Path="/", |
123 |
| - Roles=[Ref(container_instance_role)], |
124 |
| -) |
| 122 | + container_instance_profile = iam.InstanceProfile( |
| 123 | + "ContainerInstanceProfile", |
| 124 | + template=template, |
| 125 | + Path="/", |
| 126 | + Roles=[Ref(container_instance_role)], |
| 127 | + ) |
125 | 128 |
|
126 | 129 | container_instance_type = Ref(
|
127 | 130 | template.add_parameter(
|
|
0 commit comments