Created
February 10, 2020 04:42
-
-
Save maatthc/5f8331bbf845ecefcefeb7403c6a6f11 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
AWSTemplateFormatVersion: "2010-09-09" | |
Description: CloudFormation for creating Python Glue Jobs and schedule it's execution | |
Parameters: | |
ServiceName: | |
Type: String | |
Description: Name of the service | |
ArtifactBucket: | |
Type: String | |
Description: A bucket to get artefacts from | |
Default: my-company-artefacts | |
Environment: | |
Description: Name of the environment the service is being deployed. | |
Type: String | |
Version: | |
Description: Version of the Service being deployed | |
Type: String | |
Resources: | |
MyGlueEtlJob: | |
Type: AWS::Glue::Job | |
Properties: | |
Role: !Ref MyGlueEtlJobRole | |
Command: | |
Name: pythonshell | |
ScriptLocation: !Sub "s3://${ArtifactBucket}/${ServiceName}/${Version}/scripts/my_etl_job.py" | |
PythonVersion: "3" | |
DefaultArguments: | |
"--environment": !Ref Environment | |
"--enable-metrics": "true" | |
# Define external Python dependencies here | |
"--extra-py-files": !Sub "s3://${ArtifactBucket}/${ServiceName}/${Version}/lib/my_lib_-0.0.1-py3.7.egg,s3://${ArtifactBucket}/${ServiceName}/${Version}/lib/my_etl_lib-0.0.0-py3.7.egg" | |
ExecutionProperty: | |
MaxConcurrentRuns: 1 | |
MaxRetries: 1 | |
MaxCapacity: 1 | |
GlueVersion: "1.0" | |
Name: !Sub ${ServiceName}-${Environment}-my-glue-job | |
MyGlueEtlJobRole: | |
Type: AWS::IAM::Role | |
Properties: | |
ManagedPolicyArns: | |
- arn:aws:iam::aws:policy/service-role/AWSGlueServiceRole | |
AssumeRolePolicyDocument: | |
Version: 2012-10-17 | |
Statement: | |
- Effect: Allow | |
Principal: | |
Service: | |
- glue.amazonaws.com | |
Action: | |
- sts:AssumeRole | |
Path: / | |
Policies: | |
- PolicyName: !Sub ${ServiceName}-${Environment}-my-glue-job-policy | |
PolicyDocument: | |
Version: 2012-10-17 | |
Statement: | |
- Effect: Allow | |
Action: | |
- s3:GetObject | |
- s3:ListObjects | |
- s3:PutObject | |
Resource: | |
- !Sub arn:aws:s3:::my-company-${Environment}-output | |
- !Sub arn:aws:s3:::my-company-${Environment}-output/* | |
- Effect: Allow | |
Action: | |
- s3:ListObjects | |
- s3:GetObject | |
Resource: | |
- !Sub arn:aws:s3:::my-company-${Environment}-input | |
- !Sub arn:aws:s3:::my-company-${Environment}-input/* | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment