英文:
using s3 bucket arn instead of bucket name in aws terraform code pipeline definition
问题
"BucketName" = "airflow-dev-s3" # <- 是否可以传入 ARN 代替?
英文:
I want to know if there is a way to use s3 bucket arn instead of bucket name in the following aws code pipeline definition.
I have this imported with terraform and I want to reference the s3 bucket that is being created in another MWAA module.
The problem is, there is no output on the MWAA module for bucket name and it is only returning the bucket arn. I am using cloudposse to create the MWAA environment.
Here is the code for code pipeline definition:
resource "aws_codepipeline" "codepipeline" {
name = "airflow-pipeline-dev"
role_arn = "<role arn>"
tags = {}
tags_all = {}
artifact_store {
location = "codepipeline-us-east-1"
type = "S3"
}
stage {
name = "Source"
action {
.....
}
}
stage {
name = "Build"
action {
....
}
}
stage {
name = "Deploy"
action {
category = "Deploy"
configuration = {
"BucketName" = "airflow-dev-s3" # <- pass in arn instead?
"Extract" = "true"
}
input_artifacts = [
"BuildArtifact",
]
name = "Deploy"
output_artifacts = []
owner = "AWS"
provider = "S3"
region = "us-east-1"
run_order = 1
version = "1"
}
}
}
I have other module for mwaa and I can only output bucket arn from there!
答案1
得分: 1
如果无法修改其他模块以输出存储桶名称,您可以从存储桶 ARN 中提取存储桶名称。ARN 将采用以下形式:
arn:aws:s3:::<bucket_name>
因此只需使用:
分割 ARN 并取结果的最后(第六)部分:
locals {
bucketname = element(split(":", var.bucket_arn), 5)
}
英文:
If you can't modify the other module to output the bucket name, you can extract the bucket name from the bucket ARN. The ARN will have the form
arn:aws:s3:::<bucket_name>
so just split the ARN on :
and take the last (sixth) part of the result:
locals {
bucketname = element(split(":", var.bucket_arn), 5)
}
Refs:
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论