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]: After version 5.45.0 of hashicorp/aws the API root_resource_id comes empty after resource is created #37007

Closed
angeld287 opened this issue Apr 19, 2024 · 4 comments · Fixed by #37040
Assignees
Labels
bug Addresses a defect in current functionality. service/apigateway Issues and PRs that pertain to the apigateway service.
Milestone

Comments

@angeld287
Copy link

angeld287 commented Apr 19, 2024

Terraform Core Version

1.8.1

AWS Provider Version

5.45.0

Affected Resource(s)

aws_api_gateway_rest_api

Expected Behavior

The property "root_resource_id" should return the ID after the resource is created.

Actual Behavior

The property "root_resource_id" is empty after the resource is created.

Relevant Error/Panic Output Snippet

null_resource.delay (local-exec): Starting delay... | ROOT_RESOURCE_ID
null_resource.delay (local-exec): Delay finished.

│ Error: creating API Gateway Resource: operation error API Gateway: CreateResource, serialization failed: serialization failed: input member parentId must not be empty
│
│   with aws_api_gateway_resource.resource,
│   on main.tf line 29, in resource "aws_api_gateway_resource" "resource":
│   29: resource "aws_api_gateway_resource" "resource" {

Terraform Configuration Files

provider "aws" {
  region                      = "us-east-1"
  access_key                  = "mock_access_key"
  secret_key                  = "mock_secret_key"
  s3_use_path_style           = true
  skip_credentials_validation = true
  skip_metadata_api_check     = true
  skip_requesting_account_id  = true
  endpoints {
    apigateway = "http://localhost:4566"
    lambda     = "http://localhost:4566"
  }
}

resource "aws_api_gateway_rest_api" "api" {
  name        = "API Gateway Lambda integration"
  description = "API Gateway with Lambda integration"
}

resource "null_resource" "delay" {
  provisioner "local-exec" {
    command = "echo 'Starting delay... | ROOT_RESOURCE_ID ${aws_api_gateway_rest_api.api.root_resource_id}' && sleep 1 && echo 'Delay finished.'"
  }
  triggers = {
    rest_api_id = aws_api_gateway_rest_api.api.id
  }
}

resource "aws_api_gateway_resource" "resource" {
  rest_api_id = aws_api_gateway_rest_api.api.id
  parent_id   = aws_api_gateway_rest_api.api.root_resource_id
  path_part   = "{somethingId}"
}

Steps to Reproduce

tflocal init && tflocal plan && tflocal apply -auto-approve

Debug Output

tflocal init && tflocal plan && tflocal apply -auto-approve

Initializing the backend...

Initializing provider plugins...
- Finding latest version of hashicorp/aws...
- Finding latest version of hashicorp/null...
- Installing hashicorp/aws v5.46.0...
- Installed hashicorp/aws v5.46.0 (signed by HashiCorp)
- Installing hashicorp/null v3.2.2...
- Installed hashicorp/null v3.2.2 (signed by HashiCorp)

Terraform has created a lock file .terraform.lock.hcl to record the provider
selections it made above. Include this file in your version control repository
so that Terraform can guarantee to make the same selections by default when
you run "terraform init" in the future.

Terraform has been successfully initialized!

You may now begin working with Terraform. Try running "terraform plan" to see
any changes that are required for your infrastructure. All Terraform commands
should now work.

If you ever set or change modules or backend configuration for Terraform,
rerun this command to reinitialize your working directory. If you forget, other
commands will detect it and remind you to do so if necessary.

Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols:
  + create

Terraform will perform the following actions:

  # aws_api_gateway_resource.resource will be created
  + resource "aws_api_gateway_resource" "resource" {
      + id          = (known after apply)
      + parent_id   = (known after apply)
      + path        = (known after apply)
      + path_part   = "{somethingId}"
      + rest_api_id = (known after apply)
    }

  # aws_api_gateway_rest_api.api will be created
  + resource "aws_api_gateway_rest_api" "api" {
      + api_key_source               = (known after apply)
      + arn                          = (known after apply)
      + binary_media_types           = (known after apply)
      + created_date                 = (known after apply)
      + description                  = "API Gateway with Lambda integration"
      + disable_execute_api_endpoint = (known after apply)
      + execution_arn                = (known after apply)
      + id                           = (known after apply)
      + minimum_compression_size     = (known after apply)
      + name                         = "API Gateway Lambda integration"
      + policy                       = (known after apply)
      + root_resource_id             = (known after apply)
      + tags_all                     = (known after apply)
    }

  # null_resource.delay will be created
  + resource "null_resource" "delay" {
      + id       = (known after apply)
      + triggers = {
          + "rest_api_id" = (known after apply)
        }
    }

Plan: 3 to add, 0 to change, 0 to destroy.
╷
│ Warning: Invalid Attribute Combination
│
│   with provider["registry.terraform.io/hashicorp/aws"],
│   on main.tf line 1, in provider "aws":
│    1: provider "aws" {
│
│ Only one of the following attributes should be set: "endpoints[0].elasticsearch", "endpoints[0].es", "endpoints[0].elasticsearchservice"
│
│ This will be an error in a future release.
│
│ (and one more similar warning elsewhere)
╵
╷
│ Warning: AWS account ID not found for provider
│
│   with provider["registry.terraform.io/hashicorp/aws"],
│   on main.tf line 1, in provider "aws":
│    1: provider "aws" {
│
│ See https://registry.terraform.io/providers/hashicorp/aws/latest/docs#skip_requesting_account_id for implications.
╵

──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────

Note: You didn't use the -out option to save this plan, so Terraform can't guarantee to take exactly these actions if you run "terraform apply" now.

Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols:
  + create

Terraform will perform the following actions:

  # aws_api_gateway_resource.resource will be created
  + resource "aws_api_gateway_resource" "resource" {
      + id          = (known after apply)
      + parent_id   = (known after apply)
      + path        = (known after apply)
      + path_part   = "{somethingId}"
      + rest_api_id = (known after apply)
    }

  # aws_api_gateway_rest_api.api will be created
  + resource "aws_api_gateway_rest_api" "api" {
      + api_key_source               = (known after apply)
      + arn                          = (known after apply)
      + binary_media_types           = (known after apply)
      + created_date                 = (known after apply)
      + description                  = "API Gateway with Lambda integration"
      + disable_execute_api_endpoint = (known after apply)
      + execution_arn                = (known after apply)
      + id                           = (known after apply)
      + minimum_compression_size     = (known after apply)
      + name                         = "API Gateway Lambda integration"
      + policy                       = (known after apply)
      + root_resource_id             = (known after apply)
      + tags_all                     = (known after apply)
    }

  # null_resource.delay will be created
  + resource "null_resource" "delay" {
      + id       = (known after apply)
      + triggers = {
          + "rest_api_id" = (known after apply)
        }
    }

Plan: 3 to add, 0 to change, 0 to destroy.
aws_api_gateway_rest_api.api: Creating...
aws_api_gateway_rest_api.api: Creation complete after 0s [id=1yj6zp89tk]
aws_api_gateway_resource.resource: Creating...
null_resource.delay: Creating...
null_resource.delay: Provisioning with 'local-exec'...
null_resource.delay (local-exec): Executing: ["/bin/sh" "-c" "echo 'Starting delay... | ROOT_RESOURCE_ID ' && sleep 1 && echo 'Delay finished.'"]
null_resource.delay (local-exec): Starting delay... | ROOT_RESOURCE_ID
null_resource.delay (local-exec): Delay finished.
null_resource.delay: Creation complete after 1s [id=1864083649616201131]
╷
│ Warning: Invalid Attribute Combination
│
│   with provider["registry.terraform.io/hashicorp/aws"],
│   on main.tf line 1, in provider "aws":
│    1: provider "aws" {
│
│ Only one of the following attributes should be set: "endpoints[0].configservice", "endpoints[0].config"
│
│ This will be an error in a future release.
│
│ (and 3 more similar warnings elsewhere)
╵
╷
│ Warning: AWS account ID not found for provider
│
│   with provider["registry.terraform.io/hashicorp/aws"],
│   on main.tf line 1, in provider "aws":
│    1: provider "aws" {
│
│ See https://registry.terraform.io/providers/hashicorp/aws/latest/docs#skip_requesting_account_id for implications.
│
│ (and one more similar warning elsewhere)
╵
╷
│ Error: creating API Gateway Resource: operation error API Gateway: CreateResource, serialization failed: serialization failed: input member parentId must not be empty
│
│   with aws_api_gateway_resource.resource,
│   on main.tf line 29, in resource "aws_api_gateway_resource" "resource":
│   29: resource "aws_api_gateway_resource" "resource" {
│
╵

Panic Output

No response

Important Factoids

If I change the hashicorp/aws version to 5.44 it works.

References

No response

Would you like to implement a fix?

None

@angeld287 angeld287 added the bug Addresses a defect in current functionality. label Apr 19, 2024
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 Apr 19, 2024
@terraform-aws-provider terraform-aws-provider bot added the needs-triage Waiting for first response or review from a maintainer. label Apr 19, 2024
@ewbankkit ewbankkit removed the needs-triage Waiting for first response or review from a maintainer. label Apr 22, 2024
@ewbankkit ewbankkit self-assigned this Apr 22, 2024
@terraform-aws-provider terraform-aws-provider bot added the prioritized Part of the maintainer teams immediate focus. To be addressed within the current quarter. label Apr 22, 2024
Copy link

Warning

This issue has been closed, meaning that any additional comments are hard for our team to see. Please assume that the maintainers will not see them.

Ongoing conversations amongst community members are welcome, however, the issue will be locked after 30 days. Moving conversations to another venue, such as the AWS Provider forum, is recommended. If you have additional concerns, please open a new issue, referencing this one where needed.

@github-actions github-actions bot added this to the v5.47.0 milestone Apr 23, 2024
@github-actions github-actions bot removed the prioritized Part of the maintainer teams immediate focus. To be addressed within the current quarter. label Apr 26, 2024
Copy link

This functionality has been released in v5.47.0 of the Terraform AWS Provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading.

For further feature requests or bug reports with this functionality, please create a new GitHub issue following the template. Thank you!

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 May 27, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Addresses a defect in current functionality. service/apigateway Issues and PRs that pertain to the apigateway service.
Projects
None yet
2 participants