0
0

More than 1 year has passed since last update.

【Terraform】VPCエンドポイントの設定で service_name が取得できなかった場合、service から組み立てられる件

Posted at

はじめに

こちらのモジュールをつかって、VPCエンドポイントを作成する際、service_nameを渡さなくても、自動で設定されます

module "endpoints" {
  source = "terraform-aws-modules/vpc/aws//modules/vpc-endpoints"

  vpc_id             = "vpc-12345678"
  security_group_ids = ["sg-12345678"]

  endpoints = {
    s3 = {
      # interface endpoint
      service             = "s3"
      tags                = { Name = "s3-vpc-endpoint" }
    },
  }

  tags = {
    Owner       = "user"
    Environment = "dev"
  }
}

出典:https://github.com/terraform-aws-modules/terraform-aws-vpc/tree/master/modules/vpc-endpoints

上記の例から見てもわかるように、設定しているのはserviceだけです
直感的に、serviceからservice_nameが設定されていると想定されます

また、公式ドキュメントには以下のように説明されています

service_name - (Required) The service name. For AWS services the service name is usually in the form com.amazonaws.. (the SageMaker Notebook service is an exception to this rule, the service name is in the form aws.sagemaker..notebook).

service_nameは通常、com.amazonaws.<region>.<service>の形式です

ソースを確認してみた

以下で設定されているのを見つけました

	if v, ok := d.GetOk("service_name"); ok {
		serviceName = v.(string)
	} else if v, ok := d.GetOk("service"); ok {
		serviceName = fmt.Sprintf("com.amazonaws.%s.%s", meta.(*conns.AWSClient).Region, v.(string))
	}

出典: https://github.com/hashicorp/terraform-provider-aws

service_nameのフィールドは必須なのですが、取得できなかった場合に、serviceから組み立てられているのがわかります

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0