Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: unable to set "name" argument in aws_api_gateway_vpc_link when using as a module. #32101

Closed
vysh0x50 opened this issue Jun 20, 2023 · 4 comments
Labels
service/apigateway Issues and PRs that pertain to the apigateway service.

Comments

@vysh0x50
Copy link

vysh0x50 commented Jun 20, 2023

Terraform Core Version

1.5.0

AWS Provider Version

4.67.0

Affected Resource(s)

aws_api_gateway_vpc_link

Expected Behavior

It should support "name" argument as per the documentaion.

Actual Behavior

Getting the error: │ An argument named "name" is not expected here.

Relevant Error/Panic Output Snippet

╷
│ Error: Unsupported argument
│ 
│   on main.tf line 4, in module "vpclink":
│    4:   name        = var.vpclink_name
│ 
│ An argument named "name" is not expected here.
╵

Terraform Configuration Files

tree .
.
├── main.tf
├── modules
│   └── vpc_link
│       ├── main.tf
│       ├── outputs.tf
│       └── variables.tf
├── outputs.tf
├── provider.tf
├── terraform.tfstate
├── terraform.tfstate.backup
├── terraform.tfvars
└── variables.tf

-> modules/vpc_link/main.tf

resource "aws_api_gateway_vpc_link" "vpclink" {
  name        = var.vpclink_name
  target_arns = var.target_arn
}

-> modules/vpc_link/variables.tf

variable "vpclink_name" {
  type = string
  default = ""
}

variable "target_arn" {
  type = list(string)
  default = [ "" ]
}

->modules/vpc_link/outputs.tf

output "vpclink_id" {
  description = "The ID of the VPC Link"
  value       = aws_api_gateway_vpc_link.vpclink.id
}

->main.tf

module "vpclink" {
  source = "./modules/vpc_link"

  name        = var.vpclink_name
  target_arn = var.target_arn
}

->variables.tf

variable "vpclink_name" {
  type = string
  default = ""
}

variable "target_arn" {
  type = list(string)
}

->terraform.tfvars

vpclink_name = "ms-vpclink"
target_arn   = ["<<load_balancer_arn>>"]

->outputs.tf

output "vpc_link_id" {
  value = module.vpclink.id
}

Steps to Reproduce

  1. Include your name and target_arn in the terraform.tfvars
  2. terraform validate

Debug Output

2023-06-20T14:46:42.641+0530 [INFO]  Terraform version: 1.5.0
2023-06-20T14:46:42.641+0530 [DEBUG] using github.com/hashicorp/go-tfe v1.26.0
2023-06-20T14:46:42.641+0530 [DEBUG] using github.com/hashicorp/hcl/v2 v2.16.2
2023-06-20T14:46:42.641+0530 [DEBUG] using github.com/hashicorp/terraform-svchost v0.1.0
2023-06-20T14:46:42.641+0530 [DEBUG] using github.com/zclconf/go-cty v1.12.2
2023-06-20T14:46:42.641+0530 [INFO]  Go runtime version: go1.20.5
2023-06-20T14:46:42.641+0530 [INFO]  CLI args: []string{"terraform", "validate", "-no-color"}
2023-06-20T14:46:42.641+0530 [TRACE] Stdout is not a terminal
2023-06-20T14:46:42.641+0530 [TRACE] Stderr is not a terminal
2023-06-20T14:46:42.641+0530 [TRACE] Stdin is a terminal
2023-06-20T14:46:42.641+0530 [DEBUG] Attempting to open CLI config file: /home/vyshnavlal/.terraformrc
2023-06-20T14:46:42.641+0530 [DEBUG] File doesn't exist, but doesn't need to. Ignoring.
2023-06-20T14:46:42.641+0530 [DEBUG] ignoring non-existing provider search directory terraform.d/plugins
2023-06-20T14:46:42.641+0530 [DEBUG] ignoring non-existing provider search directory /home/vyshnavlal/.terraform.d/plugins
2023-06-20T14:46:42.641+0530 [DEBUG] ignoring non-existing provider search directory /home/vyshnavlal/.local/share/terraform/plugins
2023-06-20T14:46:42.641+0530 [DEBUG] ignoring non-existing provider search directory /home/vyshnavlal/.local/share/flatpak/exports/share/terraform/plugins
2023-06-20T14:46:42.641+0530 [DEBUG] ignoring non-existing provider search directory /var/lib/flatpak/exports/share/terraform/plugins
2023-06-20T14:46:42.641+0530 [DEBUG] ignoring non-existing provider search directory /usr/local/share/terraform/plugins
2023-06-20T14:46:42.641+0530 [DEBUG] ignoring non-existing provider search directory /usr/share/terraform/plugins
2023-06-20T14:46:42.641+0530 [INFO]  CLI command args: []string{"validate", "-no-color"}
2023-06-20T14:46:42.642+0530 [TRACE] providercache.fillMetaCache: scanning directory .terraform/providers
2023-06-20T14:46:42.642+0530 [TRACE] getproviders.SearchLocalDirectory: found registry.terraform.io/hashicorp/aws v4.67.0 for linux_amd64 at .terraform/providers/registry.terraform.io/hashicorp/aws/4.67.0/linux_amd64
2023-06-20T14:46:42.642+0530 [TRACE] providercache.fillMetaCache: including .terraform/providers/registry.terraform.io/hashicorp/aws/4.67.0/linux_amd64 as a candidate package for registry.terraform.io/hashicorp/aws 4.67.0
2023-06-20T14:46:43.339+0530 [DEBUG] checking for provisioner in "."
2023-06-20T14:46:43.344+0530 [DEBUG] checking for provisioner in "/usr/bin"
2023-06-20T14:46:43.344+0530 [TRACE] terraform.NewContext: starting
2023-06-20T14:46:43.344+0530 [TRACE] terraform.NewContext: complete
2023-06-20T14:46:43.344+0530 [DEBUG] Building and walking validate graph
2023-06-20T14:46:43.344+0530 [TRACE] building graph for walkValidate
2023-06-20T14:46:43.344+0530 [TRACE] Executing graph transform *terraform.ConfigTransformer
2023-06-20T14:46:43.344+0530 [TRACE] ConfigTransformer: Starting for path:
2023-06-20T14:46:43.344+0530 [TRACE] ConfigTransformer: Starting for path: module.vpclink
2023-06-20T14:46:43.344+0530 [TRACE] Completed graph transform *terraform.ConfigTransformer with new graph:
  module.vpclink.aws_api_gateway_vpc_link.vpclink - *terraform.NodeValidatableResource
  ------
2023-06-20T14:46:43.344+0530 [TRACE] Executing graph transform *terraform.RootVariableTransformer
2023-06-20T14:46:43.344+0530 [TRACE] Completed graph transform *terraform.RootVariableTransformer with new graph:
  module.vpclink.aws_api_gateway_vpc_link.vpclink - *terraform.NodeValidatableResource
  var.target_arn - *terraform.NodeRootVariable
  var.vpclink_name - *terraform.NodeRootVariable
  ------
2023-06-20T14:46:43.344+0530 [TRACE] Executing graph transform *terraform.ModuleVariableTransformer
2023-06-20T14:46:43.344+0530 [TRACE] Completed graph transform *terraform.ModuleVariableTransformer (no changes)

Error: Unsupported argument

  on main.tf line 4, in module "vpclink":
   4:   name        = var.vpclink_name

An argument named "name" is not expected here.

Panic Output

No response

Important Factoids

There are no errors when creating the resource "aws_api_gateway_vpc_link" without using a module. The documentaion includes name = "example" in the example usage.

References

Adding the respective documentation

No other source found in internet regarding the "name" behavior issue.

Would you like to implement a fix?

None

@vysh0x50 vysh0x50 added bug Addresses a defect in current functionality. needs-triage Waiting for first response or review from a maintainer. labels Jun 20, 2023
@github-actions
Copy link

Community Note

Voting for Prioritization

  • Please vote on this issue by adding a 👍 reaction to the original post to help the community and maintainers prioritize this request.
  • Please see our prioritization guide for information on how we prioritize.
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request.

Volunteering to Work on This Issue

  • If you are interested in working on this issue, please leave a comment.
  • If this would be your first contribution, please review the contribution guide.

@github-actions github-actions bot added the service/apigateway Issues and PRs that pertain to the apigateway service. label Jun 20, 2023
@justinretzolk
Copy link
Member

Hey @vyshnavlal 👋 Thank you for taking the time to raise this! In your vpc_link module, the name argument of the aws_api_gateway_vpc_link resource is set to var.vpclink_name. This (paired with the variable definition found in the modules/vpc_link/variables.tf file) means that this module expects an argument of vpclink_name, rather than name in order to set the name of the VPC link resource.

In order to correctly call the vpc_link module, you'll need to pass the arguments that it's expecting; vpclink_name and target_arn.

Note
I'm intentionally ignoring that the variables have default values. Since those values are required in order to create a functional configuration, I'd personally remove the default values, but that's a different topic entirely.

The updated configuration in main.tf would look like this:

module "vpclink" {
  source = "./modules/vpc_link"

  vpclink_name  = var.vpclink_name
  target_arn    = var.target_arn
}

@justinretzolk justinretzolk added waiting-response Maintainers are waiting on response from community or contributor. and removed bug Addresses a defect in current functionality. needs-triage Waiting for first response or review from a maintainer. labels Jun 20, 2023
@justinretzolk
Copy link
Member

Since we haven't heard back, I'm going to close this issue. If you're still having trouble, please feel free to open a new issue, referencing this one for context as needed.

@justinretzolk justinretzolk closed this as not planned Won't fix, can't repro, duplicate, stale Jan 25, 2024
@terraform-aws-provider terraform-aws-provider bot removed the waiting-response Maintainers are waiting on response from community or contributor. label Jan 25, 2024
Copy link

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 25, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
service/apigateway Issues and PRs that pertain to the apigateway service.
Projects
None yet
Development

No branches or pull requests

2 participants