-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathcloudformation.yaml
106 lines (106 loc) · 3.01 KB
/
cloudformation.yaml
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
Description: github.com/theaaf/radius-server
Parameters:
AllowedRADIUSIngress:
Type: AWS::EC2::SecurityGroup::Id
Image:
Type: String
PrivateSubnet1:
Type: AWS::EC2::Subnet::Id
PrivateSubnet2:
Type: AWS::EC2::Subnet::Id
RADIUSSharedSecret:
Type: String
NoEcho: true
VPC:
Type: AWS::EC2::VPC::Id
Resources:
Cluster:
Type: AWS::ECS::Cluster
LogGroup:
Type: AWS::Logs::LogGroup
ServiceDiscoveryNamespace:
Type: AWS::ServiceDiscovery::PrivateDnsNamespace
Properties:
Name: local
Vpc: !Ref VPC
RADIUSSecurityGroup:
Type: AWS::EC2::SecurityGroup
Properties:
GroupDescription: RADIUSSecurityGroup
SecurityGroupIngress:
- IpProtocol: udp
FromPort: 1812
ToPort: 1812
SourceSecurityGroupId: !Ref AllowedRADIUSIngress
VpcId: !Ref VPC
RADIUSTaskDefinition:
Type: AWS::ECS::TaskDefinition
Properties:
Family: !Ref AWS::StackName
ContainerDefinitions:
- Command:
- serve-radius
- --shared-secret
- !Ref RADIUSSharedSecret
- --redis
- !Sub ${Redis.PrimaryEndPoint.Address}:${Redis.PrimaryEndPoint.Port}
Image: !Ref Image
LogConfiguration:
LogDriver: awslogs
Options:
awslogs-group: !Ref LogGroup
awslogs-region: !Ref AWS::Region
awslogs-stream-prefix: !Ref AWS::StackName
MemoryReservation: 512
Name: radius
PortMappings:
- ContainerPort: 1812
Cpu: 256
ExecutionRoleArn: !Ref TaskExecutionRole
Memory: 0.5GB
NetworkMode: awsvpc
RequiresCompatibilities:
- FARGATE
Redis:
Type: AWS::ElastiCache::ReplicationGroup
Properties:
AtRestEncryptionEnabled: true
AutomaticFailoverEnabled: true
CacheNodeType: cache.m3.medium
CacheSubnetGroupName: !Ref RedisSubnetGroup
Engine: redis
EngineVersion: '3.2.6'
NumCacheClusters: 2
ReplicationGroupDescription: redis
SecurityGroupIds:
- !Ref RedisSecurityGroup
RedisSecurityGroup:
Type: AWS::EC2::SecurityGroup
Properties:
GroupDescription: RedisSecurityGroup
SecurityGroupIngress:
- IpProtocol: tcp
FromPort: 6379
ToPort: 6379
SourceSecurityGroupId: !Ref RADIUSSecurityGroup
VpcId: !Ref VPC
RedisSubnetGroup:
Type: AWS::ElastiCache::SubnetGroup
Properties:
Description: RedisSubnetGroup
SubnetIds:
- !Ref PrivateSubnet1
- !Ref PrivateSubnet2
TaskExecutionRole:
Type: AWS::IAM::Role
Properties:
AssumeRolePolicyDocument:
Version: 2012-10-17
Statement:
- Effect: Allow
Principal:
Service: ecs-tasks.amazonaws.com
Action: sts:AssumeRole
ManagedPolicyArns:
- arn:aws:iam::aws:policy/service-role/AmazonECSTaskExecutionRolePolicy
- arn:aws:iam::aws:policy/AmazonEC2ContainerRegistryReadOnly