简体   繁体   English

是否可以在Terraform API网关域名资源上更改标签信息?

[英]Is it possible to alter the tag information on a Terraform API Gateway Domain Name resource?

I am creating a Route53 URL which points to a CloudFront distribution and hits an API Gateway endpoint. 我正在创建一个Route53 URL,该URL指向CloudFront发行版并命中API Gateway端点。 I got the Terraform definitions to work and everything deployed correctly. 我得到了Terraform定义,并且一切都正确部署。 However, I need to add tags to the CloudFront distribution. 但是,我需要将标签添加到CloudFront分发中。

Here is the relevant Terraform code: 以下是相关的Terraform代码:

resource "aws_api_gateway_domain_name" "api-gateway-domain" {
    domain_name = "${var.domain_name}"
    certificate_arn = "${var.arn}
    count        = "${var.count}"
}


resource "aws_route53_record" "route53" {
    zone_id = "${data.aws_route53_zone.route53-zone.zone_id}"
    name    = "${var.domain_name}"
    type    = "A"
    alias {
      name                   = "${aws_api_gateway_domain_name.api-gateway-domain.cloudfront_domain_name}"
      zone_id                = "${aws_api_gateway_domain_name.api-gateway-domain.cloudfront_zone_id}"
      evaluate_target_health = true
    }
    count   = "${var.count}"
}

I'm wondering if I can do something like "${aws_api_gateway_domain_name.api-gateway-domain.cloudfront_domain_name.id.tags}" = { TAGS = "foobar" } or something to that effect. 我想知道我是否可以执行类似"${aws_api_gateway_domain_name.api-gateway-domain.cloudfront_domain_name.id.tags}" = { TAGS = "foobar" }或类似的操作。

Is this possible? 这可能吗? Or will I have to manually set up a CloudFront distribution to point my Route53 URL at? 还是我必须手动设置CloudFront发行版以将Route53 URL指向?

No, you cannot. 你不能。

The CloudFront Distribution that API Gateway creates is completely invisible to you; API Gateway创建的CloudFront分发对您完全不可见 you have no way of seeing it, no way of altering it. 您无法看到它,也无法更改它。 Really, the fact that they even tell you that's what it is and then give you some information such as the "Target Domain name" is incredibly confusing. 的确,他们甚至告诉您这是什么,然后给您一些信息,例如“目标域名”,这一事实令人难以置信。 It's the same as when they say "Instance store-backed AMIs are stored by S3" - But you don't have any access to the actual S3 object. 这与他们说“实例存储支持的AMI由S3存储”相同-但是您无权访问实际的S3对象。

Also, no - you will not need to create your own CloudFront Distribution; 此外,否-您无需创建自己的CloudFront发行版; however you should be able to point your Route53 record at the CloudFront Target Domain Name that shows up in the "Custom Domain Names" section of API Gateway. 但是,您应该能够将Route53记录指向API网关“自定义域名”部分中显示的CloudFront目标域名。

Neither the route53_record nor api_gateway_domain_name support a Tag block; route53_recordapi_gateway_domain_name都不支持Tag块; likely due to AWS not supporting tags on them (Which I know - crazy, considering AWS always says you should tag everything, but then doesn't provide the option to). 可能是由于AWS不支持标签(我知道-很疯狂,考虑到AWS总是说您应该标记所有内容,但随后不提供选择)。

So you're just kinda SOL on being able to tag these resources; 因此,您只是能够标记这些资源的SOL; and it won't be the last time you run into this unfortunately. 不幸的是,这不会是您最后一次遇到这种情况。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM