-
Notifications
You must be signed in to change notification settings - Fork 24
/
ecs-cluster.yml
107 lines (95 loc) · 2.77 KB
/
ecs-cluster.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
103
104
105
106
107
AWSTemplateFormatVersion: 2010-09-09
Description: Starter template for ECS
Parameters:
VpcStack:
Type: String
Description: Name of VPC stack to build off of
Default: vpc-stack
Resources:
# https://docs.aws.amazon.com/AmazonECR/latest/userguide/registry_auth.html
EcrRepo:
Type: AWS::ECR::Repository
EcsCluster:
Type: AWS::ECS::Cluster
DefaultSecurityGroup:
Type: AWS::EC2::SecurityGroup
Properties:
GroupDescription: Allow http to client host
VpcId:
Fn::ImportValue: !Sub ${VpcStack}-vpc-id
SecurityGroupIngress:
- IpProtocol: tcp
FromPort: 80
ToPort: 80
CidrIp: 0.0.0.0/0
- IpProtocol: tcp
FromPort: 8080
ToPort: 8080
CidrIp: 0.0.0.0/0
- IpProtocol: tcp
FromPort: 443
ToPort: 443
CidrIp: 0.0.0.0/0
SecurityGroupEgress:
- IpProtocol: tcp
FromPort: 80
ToPort: 80
CidrIp: 0.0.0.0/0
- IpProtocol: tcp
FromPort: 8080
ToPort: 8080
CidrIp: 0.0.0.0/0
- IpProtocol: tcp
FromPort: 443
ToPort: 443
CidrIp: 0.0.0.0/0
DefaultRole:
Type: 'AWS::IAM::Role'
Properties:
AssumeRolePolicyDocument:
Version: 2012-10-17
Statement:
- Effect: Allow
Principal:
Service:
- ec2.amazonaws.com
- ecs.amazonaws.com
- ecs-tasks.amazonaws.com
Action:
- 'sts:AssumeRole'
Path: /
ManagedPolicyArns:
- arn:aws:iam::aws:policy/service-role/AmazonECSTaskExecutionRolePolicy
- arn:aws:iam::aws:policy/AmazonECS_FullAccess
ApplicationLoadBalancer:
Type: AWS::ElasticLoadBalancingV2::LoadBalancer
Properties:
IpAddressType: ipv4
Scheme: internet-facing
SecurityGroups:
- !Ref DefaultSecurityGroup
Subnets:
- Fn::ImportValue: !Sub ${VpcStack}-public-subnet-a-id
- Fn::ImportValue: !Sub ${VpcStack}-public-subnet-b-id
Type: application
Outputs:
EcsClusterExport:
Description: A reference to the created ECS Cluster
Value: !Ref EcsCluster
Export:
Name: !Sub ${AWS::StackName}-ecs-cluster
DefaultSecurityGroupExport:
Description: A reference to the created SG
Value: !Ref DefaultSecurityGroup
Export:
Name: !Sub ${AWS::StackName}-default-security-group
DefaultRoleExport:
Description: A reference to the created IAM Role
Value: !Ref DefaultRole
Export:
Name: !Sub ${AWS::StackName}-default-role
ApplicationLoadBalancerArnExport:
Description: A reference to the created ALB
Value: !Ref ApplicationLoadBalancer
Export:
Name: !Sub ${AWS::StackName}-alb-arn