terraform 无法访问模块输出
terraform cant access module output
在 Terraform 中使用此认知模块
https://github.com/lgallard/terraform-aws-cognito-user-pool/blob/master/outputs.tf#L34
我无法访问输出变量
output "domain_cloudfront_distribution_arn" {
description = "The ARN of the CloudFront distribution"
value = var.enabled ? join("", module.aws_cognito_user_pool_stardust.domain.*.cloudfront_distribution_arn) : null
}
抛出这个错误
❯ terraform apply -var-file fixtures.us-east-1.tfvars -auto-approve
Acquiring state lock. This may take a few moments...
module.aws_cognito_user_pool_stardust.aws_cognito_user_pool.pool[0]: Refreshing state... [id=us-east-1_wEWpH9pmy]
module.aws_cognito_user_pool_stardust.aws_cognito_user_pool_domain.domain[0]: Refreshing state... [id=stardust-admin-dashboard-dev]
module.aws_cognito_user_pool_stardust.aws_cognito_identity_provider.identity_provider[0]: Refreshing state... [id=us-east-1_wEWpH9pmy:Google]
module.aws_cognito_user_pool_stardust.aws_cognito_user_group.main[1]: Refreshing state... [id=us-east-1_wEWpH9pmy/players]
module.aws_cognito_user_pool_stardust.aws_cognito_user_group.main[0]: Refreshing state... [id=us-east-1_wEWpH9pmy/owners]
module.aws_cognito_user_pool_stardust.aws_cognito_user_pool_client.client[1]: Refreshing state... [id=kifo1avcbbd2hn7phraa1fbca]
module.aws_cognito_user_pool_stardust.aws_cognito_user_pool_client.client[0]: Refreshing state... [id=4dpv821e9biuve5ri9ka319ecr]
╷
│ Error: Unsupported attribute
│
│ on outputs.tf line 18, in output "domain_cloudfront_distribution_arn":
│ 18: value = var.enabled ? join("", module.aws_cognito_user_pool_stardust.domain.*.cloudfront_distribution_arn) : null
│ ├────────────────
│ │ module.aws_cognito_user_pool_stardust is object with 14 attributes
│
│ This object does not have an attribute named "domain".
╵
Releasing state lock. This may take a few moments...
这是我的 main.tf
文件
module "aws_cognito_user_pool_stardust" {
source = "lgallard/cognito-user-pool/aws"
version = "0.14.2"
.....
}
这是模块内部的定义:
output "domain_cloudfront_distribution_arn" {
description = "The ARN of the CloudFront distribution"
value = var.enabled ? join("", aws_cognito_user_pool_domain.domain.*.cloudfront_distribution_arn) : null
}
您要做的只是将其作为主模块的输出传递,因此您需要定义:
output "domain_cloudfront_distribution_arn" {
description = "The ARN of the CloudFront distribution"
value = module.aws_cognito_user_pool_stardust.domain_cloudfront_distribution_arn
}
在 Terraform 中使用此认知模块
https://github.com/lgallard/terraform-aws-cognito-user-pool/blob/master/outputs.tf#L34
我无法访问输出变量
output "domain_cloudfront_distribution_arn" {
description = "The ARN of the CloudFront distribution"
value = var.enabled ? join("", module.aws_cognito_user_pool_stardust.domain.*.cloudfront_distribution_arn) : null
}
抛出这个错误
❯ terraform apply -var-file fixtures.us-east-1.tfvars -auto-approve
Acquiring state lock. This may take a few moments...
module.aws_cognito_user_pool_stardust.aws_cognito_user_pool.pool[0]: Refreshing state... [id=us-east-1_wEWpH9pmy]
module.aws_cognito_user_pool_stardust.aws_cognito_user_pool_domain.domain[0]: Refreshing state... [id=stardust-admin-dashboard-dev]
module.aws_cognito_user_pool_stardust.aws_cognito_identity_provider.identity_provider[0]: Refreshing state... [id=us-east-1_wEWpH9pmy:Google]
module.aws_cognito_user_pool_stardust.aws_cognito_user_group.main[1]: Refreshing state... [id=us-east-1_wEWpH9pmy/players]
module.aws_cognito_user_pool_stardust.aws_cognito_user_group.main[0]: Refreshing state... [id=us-east-1_wEWpH9pmy/owners]
module.aws_cognito_user_pool_stardust.aws_cognito_user_pool_client.client[1]: Refreshing state... [id=kifo1avcbbd2hn7phraa1fbca]
module.aws_cognito_user_pool_stardust.aws_cognito_user_pool_client.client[0]: Refreshing state... [id=4dpv821e9biuve5ri9ka319ecr]
╷
│ Error: Unsupported attribute
│
│ on outputs.tf line 18, in output "domain_cloudfront_distribution_arn":
│ 18: value = var.enabled ? join("", module.aws_cognito_user_pool_stardust.domain.*.cloudfront_distribution_arn) : null
│ ├────────────────
│ │ module.aws_cognito_user_pool_stardust is object with 14 attributes
│
│ This object does not have an attribute named "domain".
╵
Releasing state lock. This may take a few moments...
这是我的 main.tf
文件
module "aws_cognito_user_pool_stardust" {
source = "lgallard/cognito-user-pool/aws"
version = "0.14.2"
.....
}
这是模块内部的定义:
output "domain_cloudfront_distribution_arn" {
description = "The ARN of the CloudFront distribution"
value = var.enabled ? join("", aws_cognito_user_pool_domain.domain.*.cloudfront_distribution_arn) : null
}
您要做的只是将其作为主模块的输出传递,因此您需要定义:
output "domain_cloudfront_distribution_arn" {
description = "The ARN of the CloudFront distribution"
value = module.aws_cognito_user_pool_stardust.domain_cloudfront_distribution_arn
}