terraform-provider-aws icon indicating copy to clipboard operation
terraform-provider-aws copied to clipboard

feat: Add required suffix when specifying log group ARN

Open djsd123 opened this issue 1 year ago • 2 comments

Description

Specifying a cloudwatch log-group ARN on an aws_fis_experiment_template like so:

  log_configuration {
    log_schema_version = 2

    cloudwatch_logs_configuration {
      log_group_arn = aws_cloudwatch_log_group.example.arn
    }
  }

results in:

╷
│ Error: creating AWS FIS (Fault Injection Simulator) Experiment Template (Test dev provider): operation error fis: CreateExperimentTemplate, https response error StatusCode: 400,
| RequestID: a84b03ea-b1ff-49f5-9be6-b0ad450666cf, ValidationException: The logGroupArn "arn:aws:logs:eu-west-1:${accountId}:log-group:/aws/fis" in cloudWatchLogsLogConfiguration is not valid.
│
│   with aws_fis_experiment_template.fis,
│   on fis.tf line 1, in resource "aws_fis_experiment_template" "fis":
│    1: resource "aws_fis_experiment_template" "fis" {
│
╵

This is because AWS expects this suffix :* on the log-group ARN like so:

  log_configuration {
    log_schema_version = 2

    cloudwatch_logs_configuration {
      log_group_arn = "${aws_cloudwatch_log_group.example.arn}:*"
    }
  }

As far as I can tell, the requirement for the suffix is not well documented. Also, the ambiguous Api error from AWS is not helpful. Propose the required suffix is added if not present. Specifying log_group_arn = aws_cloudwatch_log_group.example.arn is more intuitive imho.

Output from Acceptance Testing

Acceptance

➜  terraform-provider-aws git:(f-add-suffix-to-log-group-arn) ✗ make testacc TESTS=TestAccFISExperimentTemplate_loggingConfiguration PKG=fis
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./internal/service/fis/... -v -count 1 -parallel 20 -run='TestAccFISExperimentTemplate_loggingConfiguration'  -timeout 360m
=== RUN   TestAccFISExperimentTemplate_loggingConfiguration
=== PAUSE TestAccFISExperimentTemplate_loggingConfiguration
=== CONT  TestAccFISExperimentTemplate_loggingConfiguration
--- PASS: TestAccFISExperimentTemplate_loggingConfiguration (74.06s)
PASS
ok      github.com/hashicorp/terraform-provider-aws/internal/service/fis        76.509s

Unit

➜  terraform-provider-aws git:(f-add-suffix-to-log-group-arn) ✗ make test PKG=fis
==> Checking that code complies with gofmt requirements...
go test ./internal/service/fis/...  -timeout=5m
ok      github.com/hashicorp/terraform-provider-aws/internal/service/fis        2.911s

djsd123 avatar Feb 22 '24 17:02 djsd123

Community Note

Voting for Prioritization

  • Please vote on this pull request by adding a 👍 reaction to the original post to help the community and maintainers prioritize this pull 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.

For Submitters

  • Review the contribution guide relating to the type of change you are making to ensure all of the necessary steps have been taken.
  • For new resources and data sources, use skaff to generate scaffolding with comments detailing common expectations.
  • Whether or not the branch has been rebased will not impact prioritization, but doing so is always a welcome surprise.

github-actions[bot] avatar Feb 22 '24 17:02 github-actions[bot]

Thank you for your contribution! :rocket:

Please note that typically Go dependency changes are handled in this repository by dependabot or the maintainers. This is to prevent pull request merge conflicts and further delay reviews of contributions. Remove any changes to the go.mod or go.sum files and commit them into this pull request.

Additional details:

  • Check open pull requests with the dependencies label to view other dependency updates.
  • If this pull request includes an update the AWS Go SDK (or any other dependency) version, only updates submitted via dependabot will be merged. This pull request will need to remove these changes and will need to be rebased after the existing dependency update via dependabot has been merged for this pull request to be reviewed.
  • If this pull request is for supporting a new AWS service:
    • Ensure the new AWS service changes are following the Contributing Guide section on new services, in particular that the dependency addition and initial provider support are in a separate pull request from other changes (e.g. new resources). Contributions not following this item will not be reviewed until the changes are split.
    • If this pull request is already a separate pull request from the above item, you can ignore this message.

github-actions[bot] avatar Feb 22 '24 17:02 github-actions[bot]