-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtemplate.yml
More file actions
100 lines (94 loc) · 2.93 KB
/
template.yml
File metadata and controls
100 lines (94 loc) · 2.93 KB
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
AWSTemplateFormatVersion: '2010-09-09'
Parameters:
Subnets:
Type: AWS::SSM::Parameter::Value<List<String>>
Default: /defaultvpc/subnet/ids/stringList
SecurityGroups:
Type: AWS::SSM::Parameter::Value<List<String>>
Default: /defaultvpc/securitygroup/ids/stringList
Resources:
BatchJobRole:
Type: AWS::IAM::Role
Properties:
ManagedPolicyArns:
- arn:aws:iam::aws:policy/AWSBatchFullAccess
- arn:aws:iam::aws:policy/AmazonECS_FullAccess
AssumeRolePolicyDocument:
Version: '2012-10-17'
Statement:
- Effect: Allow
Principal:
Service:
- batch.amazonaws.com
- ecs.amazonaws.com
- ecs-tasks.amazonaws.com
Action: [ sts:AssumeRole ]
Policies:
- PolicyName: TestJobPermissions
PolicyDocument:
Version: '2012-10-17'
Statement:
- Effect: Allow
Action:
- ecr:*
- logs:*
- ssm:*
Resource: "*"
BatchComputeEnvironment:
Type: AWS::Batch::ComputeEnvironment
Properties:
ComputeEnvironmentName: "TestJobComputeEnv"
Type: MANAGED
ServiceRole: !GetAtt BatchJobRole.Arn
ComputeResources:
Type: FARGATE
MaxvCpus: 1
Subnets: !Ref Subnets
SecurityGroupIds: !Ref SecurityGroups
BatchJobQueue:
Type: AWS::Batch::JobQueue
Properties:
JobQueueName: "TestJobQueue"
Priority: 1
ComputeEnvironmentOrder:
- Order: 1
ComputeEnvironment: !Ref BatchComputeEnvironment
BatchLogGroup:
Type: AWS::Logs::LogGroup
Properties:
LogGroupName: !Sub "/aws/batch/job/TestJobDefinition-${AWS::AccountId}-${AWS::Region}"
RetentionInDays: 7
BatchJobDefinition:
Type: AWS::Batch::JobDefinition
Properties:
JobDefinitionName: "TestJobDefinition"
Type: container
PlatformCapabilities:
- FARGATE
ContainerProperties:
Image: !Sub "${AWS::AccountId}.dkr.ecr.${AWS::Region}.amazonaws.com/batch-jobs/test-job:latest"
NetworkConfiguration:
AssignPublicIp: ENABLED
LogConfiguration:
LogDriver: awslogs
Options:
awslogs-group: !Ref BatchLogGroup
awslogs-region: !Ref AWS::Region
awslogs-stream-prefix: batch
ResourceRequirements:
- Type: VCPU
Value: '0.25'
- Type: MEMORY
Value: '512'
Command: ["java", "-jar", "target/aws-batch-task-1.0-SNAPSHOT.jar"]
JobRoleArn: !GetAtt BatchJobRole.Arn
ExecutionRoleArn: !GetAtt BatchJobRole.Arn
RetryStrategy:
Attempts: 1
Outputs:
JobQueueName:
Description: "Name of the Batch Job Queue"
Value: !Ref BatchJobQueue
ComputeEnvironmentName:
Description: "Name of the Batch Compute Environment"
Value: !Ref BatchComputeEnvironment