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

aws_cloudwatch_event_target - http_target - path_parameter_values not created in version >=4.0.0 #23805

Closed
stevendjames opened this issue Mar 22, 2022 · 4 comments · Fixed by #23862
Labels
bug Addresses a defect in current functionality. service/events Issues and PRs that pertain to the events service. service/iam Issues and PRs that pertain to the iam service.
Milestone

Comments

@stevendjames
Copy link

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • 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
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

Terraform CLI and Terraform AWS Provider Version

Affected Resource(s)

terraform: v1.1.7
hashicorp/aws: v4.6.0

Terraform Configuration Files

terraform {
  required_version = "1.1.7"
  required_providers {
    aws = {
      source  = "hashicorp/aws"
      version = "4.6.0"
    }
  }
}

provider "aws" {
  region = "eu-west-2"
}

resource "aws_iam_role" "test_http_params" {
  name                 = "test-http-params"
  
  assume_role_policy = <<EOF
{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Action": "sts:AssumeRole",
      "Principal": {
        "Service": "events.amazonaws.com"
      },
      "Effect": "Allow",
      "Sid": ""
    }
  ]
}
EOF
}

resource "aws_cloudwatch_event_bus" "test_http_params" {
  name = "test-http-params"
}

resource "aws_cloudwatch_event_rule" "test_http_params" {
  name        = "test-http-params"
  description = "test-http-params"
  event_bus_name = aws_cloudwatch_event_bus.test_http_params.name
  event_pattern = jsonencode({
    source      = [{"prefix": "" }]
  })
}

resource "aws_cloudwatch_event_target" "replication" {
  rule           = aws_cloudwatch_event_rule.test_http_params.name
  event_bus_name = aws_cloudwatch_event_bus.test_http_params.name
  arn            = aws_cloudwatch_event_api_destination.test_http_params.arn
  role_arn       = aws_iam_role.test_http_params.arn
  http_target {
    path_parameter_values = ["param"]
  }
}

resource "aws_cloudwatch_event_connection" "test_http_params" {
  name               = "test_http_params"
  description        = "test"
  authorization_type = "BASIC"

  auth_parameters {
    basic {
      username = "user"
      password = "notarealpassword"
    }
  }
}

resource "aws_cloudwatch_event_api_destination" "test_http_params" {
  name                             = "test_http_params"
  description                      = "An API Destination"
  invocation_endpoint              = "https://fakewebsite.com/*"
  http_method                      = "POST"
  connection_arn                   = aws_cloudwatch_event_connection.test_http_params.arn
}

Expected Behavior

The terraform apply output lists the intended creation of the aws_cloudwatch_event_target with the http_target argument populated as per the configuration:

  # aws_cloudwatch_event_target.replication will be created
  + resource "aws_cloudwatch_event_target" "replication" {
      + arn            = (known after apply)
      + event_bus_name = "test-http-params"
      + id             = (known after apply)
      + role_arn       = (known after apply)
      + rule           = "test-http-params"
      + target_id      = (known after apply)

      + http_target {
          + path_parameter_values = [
              + "param",
            ]
        }
    }

Actual Behavior

After the creation of the resource, examining the aws_cloudwatch_event_target resource from the Terraform state shows an empty http_target argument:

$ terraform state show aws_cloudwatch_event_target.replication                                                                                  # aws_cloudwatch_event_target.replication:
resource "aws_cloudwatch_event_target" "replication" {
    arn            = "arn:aws:events:eu-west-2:xxxxxxxxxxxx:api-destination/test_http_params/5ab84ad6-6273-488b-a00e-9eacb8f3cbca"
    event_bus_name = "test-http-params"
    id             = "test-http-params-test-http-params-terraform-20220322092735940500000001"
    role_arn       = "arn:aws:iam::xxxxxxxxxxxx:role/test-http-params"
    rule           = "test-http-params"
    target_id      = "terraform-20220322092735940500000001"

    http_target {}
}

Steps to Reproduce

  1. terraform apply

Important Factoids

hashicorp/aws versions before v4.0.0 work as desired.
v3.75.0 outputs shown below:

  # aws_cloudwatch_event_target.replication will be created
  + resource "aws_cloudwatch_event_target" "replication" {
      + arn            = (known after apply)
      + event_bus_name = "test-http-params"
      + id             = (known after apply)
      + role_arn       = (known after apply)
      + rule           = "test-http-params"
      + target_id      = (known after apply)

      + http_target {
          + path_parameter_values = [
              + "param",
            ]
        }
    }
$ terraform state show aws_cloudwatch_event_target.replication
# aws_cloudwatch_event_target.replication:
resource "aws_cloudwatch_event_target" "replication" {
    arn            = "arn:aws:events:eu-west-2:xxxxxxxxxxxx:api-destination/test_http_params/4646563e-1b35-4612-883c-4b674052e53f"
    event_bus_name = "test-http-params"
    id             = "test-http-params-test-http-params-terraform-20220322093630327500000001"
    role_arn       = "arn:aws:iam::xxxxxxxxxxxx:role/test-http-params"
    rule           = "test-http-params"
    target_id      = "terraform-20220322093630327500000001"

    http_target {
        path_parameter_values = [
            "param",
        ]
    }
}

References

Maybe linked to this change?

@github-actions github-actions bot added needs-triage Waiting for first response or review from a maintainer. service/events Issues and PRs that pertain to the events service. service/iam Issues and PRs that pertain to the iam service. labels Mar 22, 2022
@timo-reymann
Copy link

timo-reymann commented Mar 22, 2022

In this cases it seems that the path_parameter_values are "emptied":

e. g. with two path parameter values on level WARN the following is logged:

[WARN]  Provider "provider[\"registry.terraform.io/hashicorp/aws\"]" produced an unexpected new value for aws_cloudwatch_event_target.****, but we are tolerating it because it is using the legacy plugin SDK.
    The following problems may be the cause of any confusing errors from downstream operations:
      - .http_target[0].path_parameter_values: element 0 has vanished
      - .http_target[0].path_parameter_values: element 1 has vanished

@justinretzolk justinretzolk added bug Addresses a defect in current functionality. and removed needs-triage Waiting for first response or review from a maintainer. labels Mar 23, 2022
@DrFaust92
Copy link
Collaborator

I can reproduce the issue with an acceptance test. fix coming up.

@github-actions
Copy link

This functionality has been released in v4.8.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!

@github-actions
Copy link

github-actions bot commented May 6, 2022

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 6, 2022
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/events Issues and PRs that pertain to the events service. service/iam Issues and PRs that pertain to the iam service.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants