【发布时间】:2021-07-26 18:06:33
【问题描述】:
这更多是我缺乏理解,但我似乎无法调试它。 我创建了一个运行 terraform apply 的代码管道(它在内部为我创建了 aws 基础设施)。代码管道似乎正在工作。
我需要为另一个帐户实现相同的代码管道,我该怎么做。
我尝试使用以下命令获取 json 脚本。
aws codepipeline get-pipeline --name
我将 json 脚本转换为 yaml 脚本。
当我尝试在另一个帐户上运行 yaml 脚本时,出现以下错误
Template format error: At least one Resources member must be defined.
问题: 1.) 我可以将代码管道导出到 cloudformation 模板的最佳方式 2.) 我用的方法不行,怎么解决?
{
"pipeline": {
"name": "my-code-pipeline",
"roleArn": "arn:aws:iam::aws-account-id:role/service-role/AWSCodePipelineServiceRole-aws-region-my-code-pipeline",
"artifactStore": {
"type": "S3",
"location": "codepipeline-aws-region-45856771421"
},
"stages": [
{
"name": "Source",
"actions": [
{
"name": "Source",
"actionTypeId": {
"category": "Source",
"owner": "ThirdParty",
"provider": "GitHub",
"version": "1"
},
"runOrder": 1,
"configuration": {
"Branch": "master",
"OAuthToken": "****",
"Owner": "github-account-name",
"PollForSourceChanges": "false",
"Repo": "repo-name"
},
"outputArtifacts": [
{
"name": "SourceArtifact"
}
],
"inputArtifacts": [],
"region": "aws-region",
"namespace": "SourceVariables"
}
]
},
{
"name": "codebuild-for-terraform-init-and-plan",
"actions": [
{
"name": "codebuild-for-terraform-init",
"actionTypeId": {
"category": "Build",
"owner": "AWS",
"provider": "CodeBuild",
"version": "1"
},
"runOrder": 1,
"configuration": {
"ProjectName": "my-code-pipeline-build-stage"
},
"outputArtifacts": [],
"inputArtifacts": [
{
"name": "SourceArtifact"
}
],
"region": "aws-region"
}
]
},
{
"name": "manual-approve",
"actions": [
{
"name": "approval",
"actionTypeId": {
"category": "Approval",
"owner": "AWS",
"provider": "Manual",
"version": "1"
},
"runOrder": 1,
"configuration": {
"NotificationArn": "arn:aws:sns:aws-region:aws-account-id:Email-Service"
},
"outputArtifacts": [],
"inputArtifacts": [],
"region": "aws-region"
}
]
},
{
"name": "codebuild-for-terraform-apply",
"actions": [
{
"name": "codebuild-for-terraform-apply",
"actionTypeId": {
"category": "Build",
"owner": "AWS",
"provider": "CodeBuild",
"version": "1"
},
"runOrder": 1,
"configuration": {
"ProjectName": "codebuild-project-for-apply"
},
"outputArtifacts": [],
"inputArtifacts": [
{
"name": "SourceArtifact"
}
],
"region": "aws-region"
}
]
}
],
"version": 11
},
"metadata": {
"pipelineArn": "arn:aws:codepipeline:aws-region:aws-account-id:my-code-pipeline",
"created": "2020-09-17T13:12:50.085000+05:30",
"updated": "2020-09-21T15:46:19.613000+05:30"
}
}
给定的代码是我用来创建 cloudformation 模板的 yaml 模板。
【问题讨论】:
-
模板的其余部分在哪里?
-
@Marcin,尝试下面的命令
aws codepipeline get-pipeline --name给了我 json 格式的模板,转换为 yaml,这就是我得到的。 -
@Marcin,您是否可以推荐一些步骤来获取示例代码管道的 cloudformation 模板。 (我希望在多个帐户以及多个区域中使用相同的管道,最好的选择似乎已经创建了一个 cloudformation 模板。
-
您必须手动创建此类模板或查看第三方工具,例如前2.
-
@Marcin ,我查看了第三方工具,例如former2,但它给出了同样的问题。手动操作是唯一的选择。
标签: amazon-web-services terraform amazon-cloudformation aws-codepipeline aws-cloudformation-custom-resource