Amazon cloudformation 自动上传胶水脚本
我们目前正在使用云形成来创建一个粘合作业(通过codebuild和codepipeline)。有一件事我们被卡住了,那就是如何自动化胶水作业中的代码 我们当前相关的cloudformation模板如下所示:Amazon cloudformation 自动上传胶水脚本,amazon-cloudformation,aws-glue,Amazon Cloudformation,Aws Glue,我们目前正在使用云形成来创建一个粘合作业(通过codebuild和codepipeline)。有一件事我们被卡住了,那就是如何自动化胶水作业中的代码 我们当前相关的cloudformation模板如下所示: MyJob: Type: AWS::Glue::Job Properties: Command: Name: glueetl ScriptLocation: "s3://aws-glue-scripts//your-script-f
MyJob:
Type: AWS::Glue::Job
Properties:
Command:
Name: glueetl
ScriptLocation: "s3://aws-glue-scripts//your-script-file.py"
DefaultArguments:
"--job-bookmark-option": "job-bookmark-enable"
ExecutionProperty:
MaxConcurrentRuns: 2
MaxRetries: 0
Name: cf-job1
Role: !Ref MyJobRole
问题在于“脚本位置”。看起来它必须是S3位置。我们怎样才能自动上传这个。代码在我们的Git存储库中的一个.py文件中,我假设它和代码构建过程一样被上传到工件存储库,但是如何访问它呢
我想听听其他人是怎么做的。谢谢
编辑:我找到了一篇类似的堆栈溢出帖子:但答案确实没有给出解决方案,也没有理解提出的问题。我写这篇文章是为了处理堆栈依赖项的上传,包括CloudFormation嵌套模板和非内联Lambda函数
目前还没有处理AWS胶水,因为我还没有在任何项目中尝试过。但它应该很容易扩展,以支持胶水
依赖项在单独的配置文件中定义,工具中的一段代码负责配置。以下是示例配置:
嵌套云形成模板:
# DEPENDS=( <ParameterName>=<NestedTemplate> )
#
# Required: Yes if has nested template, otherwise No
# Default: None
# Syntax:
# <ParameterName>: The name of template parameter that is referred at the
# value of nested template property `TemplateURL`.
# <NestedTemplate>: A local path or a S3 URL starting with `s3://` or
# `https://` pointing to the nested template.
# The nested templates at local is going to be uploaded
# to S3 Bucket automatically during the deployment.
# Description:
# Double quote the pairs which contain whitespaces or special characters.
# Use `#` to comment out.
# ---
# Example:
# DEPENDS=(
# NestedTemplateFooURL=/path/to/nested/foo/stack.json
# NestedTemplateBarURL=/path/to/nested/bar/stack.json
# )
我正在考虑将诸如CloudFormation模板、Lambda函数和Glue之类的依赖项抽象为一个用于配置和处理程序的接口。
这将使向部署程序添加新的依赖处理程序变得更容易
# LAMBDA=( <S3BucketParameterName>:<S3KeyParameterName>=<LambdaFunction> )
#
# Required: Yes if has None-inline Lambda Function, otherwise No
# Default: None
# Syntax:
# <S3BucketParameterName>: The name of template parameter that is referred
# at the value of Lambda property `Code.S3Bucket`.
# <S3KeyParameterName>: The name of template parameter that is referred
# at the value of Lambda property `Code.S3Key`.
# <LambdaFunction>: A local path or a S3 URL starting with `s3://` pointing
# to the Lambda Function.
# The Lambda Functions at local is going to be zipped and
# uploaded to S3 Bucket automatically during the deployment.
# Description:
# Double quote the pairs which contain whitespaces or special characters.
# Use `#` to comment out.
# ---
# Example:
# DEPENDS=(
# S3BucketForLambdaFoo:S3KeyForLambdaFoo=/path/to/LambdaFoo.py
# S3BucketForLambdaBar:S3KeyForLambdaBar=s3://mybucket/LambdaBar.py
# )
$ xsh aws/cfn/deploy -C /path/to/your/template-and-config-dir -t stack.json -c sample.conf