forked from kgmanasa/appache
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcf.yml
107 lines (104 loc) · 3.05 KB
/
cf.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: An example CloudFormation template for Fargate.
Resources:
ECSCluster:
Type: 'AWS::ECS::Cluster'
Properties:
ClusterName: democluster
ECSTaskdefinition:
Type: 'AWS::ECS::TaskDefinition'
Properties:
Family: demo-task
Cpu: .5 vCPU
Memory: 1 GB
NetworkMode: awsvpc
ExecutionRoleArn: arn:aws:iam::518214089835:role/ecs-role
RequiresCompatibilities:
- FARGATE
ContainerDefinitions:
- Name: "Demo-container"
Image: "manasakg/my-appache:v2"
Essential: true
PortMappings:
- ContainerPort: 80
LoadBalancer:
Type: AWS::ElasticLoadBalancingV2::LoadBalancer
Properties:
Type: application
Name: DemoloadBalancer
Scheme: internet-facing
Subnets:
- subnet-0a2f6d226c45267f1
- subnet-0ef2043d280ab3473
SecurityGroups:
- sg-064b71da7d57df26a
TargetGroup:
Type: AWS::ElasticLoadBalancingV2::TargetGroup
Properties:
Name: Demotarget
Port: 80
Protocol: HTTP
VpcId: vpc-0fc64df872e7e2dcd
TargetType: ip
HealthCheckIntervalSeconds: 60
HealthCheckProtocol: HTTP
HealthCheckPath: /health
HealthCheckTimeoutSeconds: 5
UnhealthyThresholdCount: 2
HealthyThresholdCount: 2
ListenerHTTPS:
Type: AWS::ElasticLoadBalancingV2::Listener
Properties:
DefaultActions:
- TargetGroupArn: !Ref TargetGroup
Type: forward
LoadBalancerArn: !Ref LoadBalancer
Port: 80
Protocol: HTTP
ECSservice:
Type: 'AWS::ECS::Service'
DependsOn:
- ListenerHTTPS
Properties:
Cluster: !Ref ECSCluster
ServiceName: demoservice
TaskDefinition: !Ref ECSTaskdefinition
DesiredCount: 2
LaunchType: FARGATE
LoadBalancers:
- ContainerName: Demo-container
ContainerPort: 80
TargetGroupArn: !Ref TargetGroup
NetworkConfiguration:
AwsvpcConfiguration:
AssignPublicIp: ENABLED
SecurityGroups:
- sg-064b71da7d57df26a
Subnets:
- subnet-0a2f6d226c45267f1
- subnet-0ef2043d280ab3473
TaskRole:
Type: AWS::IAM::Role
Properties:
RoleName: Demorole
AssumeRolePolicyDocument:
Statement:
- Effect: Allow
Principal:
Service:
- ecs-tasks.amazonaws.com
- ecs.amazonaws.com
Action: 'sts:AssumeRole'
ManagedPolicyArns:
- arn:aws:iam::aws:policy/CloudWatchFullAccess
- arn:aws:iam::aws:policy/AmazonS3FullAccess
SecurityGroup:
Type: AWS::EC2::SecurityGroup
Properties:
GroupDescription: allow traffic to containers
VpcId: vpc-0fc64df872e7e2dcd
SecurityGroupIngress:
- IpProtocol: tcp
FromPort: 80
ToPort: 80
CidrIp: 0.0.0.0/0