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

New Resource: aws_ce_anomaly_monitor #25177

Merged
merged 27 commits into from
Jun 9, 2022

Conversation

brittandeyoung
Copy link
Collaborator

@brittandeyoung brittandeyoung commented Jun 4, 2022

Community Note

  • Please vote on this pull request by adding a 👍 reaction to the original pull request comment 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 pull request followers and do not help prioritize the request

Relates #16137

Output from acceptance testing:

➜ terraform-provider-aws (f-aws_ce_anomaly_monitor) ✗ make testacc TESTARGS='-run=TestAccCEAnomalyMonitor_' PKG_NAME=internal/service/ce 
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./internal/service/ce/... -v -count 1 -parallel 20  -run=TestAccCEAnomalyMonitor_ -timeout 180m
=== RUN   TestAccCEAnomalyMonitor_dimensionalserial
=== RUN   TestAccCEAnomalyMonitor_dimensionalserial/ContainerService
=== RUN   TestAccCEAnomalyMonitor_dimensionalserial/ContainerService/basic
=== RUN   TestAccCEAnomalyMonitor_dimensionalserial/ContainerService/disappears
=== RUN   TestAccCEAnomalyMonitor_dimensionalserial/ContainerService/name
=== RUN   TestAccCEAnomalyMonitor_dimensionalserial/ContainerService/tags
=== PAUSE TestAccCEAnomalyMonitor_dimensionalserial/ContainerService/tags
=== CONT  TestAccCEAnomalyMonitor_dimensionalserial/ContainerService/tags
--- PASS: TestAccCEAnomalyMonitor_dimensionalserial (116.34s)
    --- PASS: TestAccCEAnomalyMonitor_dimensionalserial/ContainerService (70.03s)
        --- PASS: TestAccCEAnomalyMonitor_dimensionalserial/ContainerService/basic (21.69s)
        --- PASS: TestAccCEAnomalyMonitor_dimensionalserial/ContainerService/disappears (15.16s)
        --- PASS: TestAccCEAnomalyMonitor_dimensionalserial/ContainerService/name (33.19s)
        --- PASS: TestAccCEAnomalyMonitor_dimensionalserial/ContainerService/tags (46.30s)
=== RUN   TestAccCEAnomalyMonitor_Dimension
=== PAUSE TestAccCEAnomalyMonitor_Dimension
=== RUN   TestAccCEAnomalyMonitor_Type
=== PAUSE TestAccCEAnomalyMonitor_Type
=== RUN   TestAccCEAnomalyMonitor_Custom
=== PAUSE TestAccCEAnomalyMonitor_Custom
=== CONT  TestAccCEAnomalyMonitor_Dimension
=== CONT  TestAccCEAnomalyMonitor_Custom
=== CONT  TestAccCEAnomalyMonitor_Type
--- PASS: TestAccCEAnomalyMonitor_Type (4.10s)
--- PASS: TestAccCEAnomalyMonitor_Dimension (4.46s)
--- PASS: TestAccCEAnomalyMonitor_Custom (21.71s)
PASS
ok      github.com/hashicorp/terraform-provider-aws/internal/service/ce 141.493s
...

@github-actions github-actions bot added provider Pertains to the provider itself, rather than any interaction with AWS. service/ce Issues and PRs that pertain to the ce service. tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure. needs-triage Waiting for first response or review from a maintainer. size/XL Managed by automation to categorize the size of a PR. labels Jun 4, 2022
@brittandeyoung brittandeyoung changed the title [WIP] New Resources: aws_ce_anomaly_monitor [WIP] New Resource: aws_ce_anomaly_monitor Jun 4, 2022
@DrFaust92 DrFaust92 added new-resource Introduces a new resource. and removed needs-triage Waiting for first response or review from a maintainer. labels Jun 5, 2022
@github-actions github-actions bot added the documentation Introduces or discusses updates to documentation. label Jun 6, 2022
@zhelding
Copy link
Contributor

zhelding commented Jun 6, 2022

Hi @brittandeyoung, thanks so much for the pull request!

I've actually been taking a look at this myself recently -- so your contribution comes at a very opportune time.

I'll be working on this today and will push any progress. If you have any questions or any specific problems you'd like me to address, do let me know.

@brittandeyoung
Copy link
Collaborator Author

brittandeyoung commented Jun 6, 2022

@zhelding great to hear! I currently have a few changes locally that I will be pushing up soon. I have been messing with the generate.go file to try to get tagging working. And I have added some additional attribute validations with tests for those validations.

The generate file is tricky with knowing which flag does which, and it takes a long time to regenerate all files. Is there any way to just target a single generate.go file? This would greatly speed up testing the different flags and getting the tags file to generate properly.

* Added `generate.go`
* generated `tags_gen.go`
* Added resource tagging
* Added additional attribute `ConflictsWith`
* added related tests
@github-actions github-actions bot added generators Relates to code generators. tags Pertains to resource tagging. labels Jun 6, 2022
@brittandeyoung
Copy link
Collaborator Author

@zhelding I was able to figure out the proper flags for the generate.go file to get the tags_gen.go file created correctly for the ce service. I have pushed all of my latest changes just now and updated the pull request comment with the new test runs.

@brittandeyoung
Copy link
Collaborator Author

brittandeyoung commented Jun 6, 2022

SO the [Semgrep Naming Scan](https://github.com/hashicorp/terraform-provider-aws/runs/6760217861?check_suite_focus=true#logs) test seems to fail randomly with an index error.
(Invalid_argument "index out of bounds")

These checks pass locally.

@brittandeyoung
Copy link
Collaborator Author

okay @zhelding , I have the changes that I wanted to make all pushed. At this point I may need some guidance on what additional changes are needed.

@zhelding
Copy link
Contributor

zhelding commented Jun 6, 2022

@brittandeyoung thanks so much!

The failing semgrep check you mentioned is actually currently failing randomly across pull requests due to an underlying semgrep bug -- so, we're good to ignore it.

Reviewing everything now; will keep you posted!

@zhelding zhelding self-requested a review June 6, 2022 18:04
zhelding and others added 7 commits June 6, 2022 16:32
- Amend name of serial acceptance test; should end with "_serial"
- Amend name of top-level object in serial test; should match resource
- Use acctest.ResourcePrefix constant in place of "tf-acc-test"
- Amend anomaly monitor exists test with better error logging
- Amend ListTags function to handle err if returned to resolve ineffectual assignment to err
- Amend update function to properly retrieve "name" attribute when performing an update of the Anomaly Monitor Name.
- Add TestCheckResourceAttrSetchecks on basic and Custom tests.
- Fixed resource docs resource name
- Amend ARN check to ensure proper format
- Remove ForceNew from "name"; can be updated in place
- Correct reference to state attribute "Name" -> "name" in update function
- Amend reference to cost category
@brittandeyoung brittandeyoung changed the title [WIP] New Resource: aws_ce_anomaly_monitor New Resource: aws_ce_anomaly_monitor Jun 8, 2022
- Use constants in place of hard-coded strings for ValidateFunc
- Amend attribute names to bring more in line with SDK
- Clarify comment re: DIMENSIONAL monitor type serial testing
- Remove tests for bad type and dimension attributes
  - Amended validation functions already catch bad monitor_type and
    monitor_dimension attributes
  - Neither type nor dimension can be updated -- and we already test
    setting them in the basic test, so nothing more to test
- Add JSON validation to monitor_specification
@zhelding zhelding self-assigned this Jun 9, 2022
@zhelding
Copy link
Contributor

zhelding commented Jun 9, 2022

Acceptance tests have been reviewed to ensure coverage of desired resource functionality and are passing as of latest commit 7611c21:

❯ make testacc TESTS=TestAccCEAnomalyMonitor PKG=ce
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./internal/service/ce/... -v -count 1 -parallel 20 -run='TestAccCEAnomalyMonitor'  -timeout 180m
=== RUN   TestAccCEAnomalyMonitor_basic
=== PAUSE TestAccCEAnomalyMonitor_basic
=== RUN   TestAccCEAnomalyMonitor_disappears
=== PAUSE TestAccCEAnomalyMonitor_disappears
=== RUN   TestAccCEAnomalyMonitor_update
=== PAUSE TestAccCEAnomalyMonitor_update
=== RUN   TestAccCEAnomalyMonitor_tags
=== PAUSE TestAccCEAnomalyMonitor_tags
=== RUN   TestAccCEAnomalyMonitor_Dimensional
=== PAUSE TestAccCEAnomalyMonitor_Dimensional
=== CONT  TestAccCEAnomalyMonitor_basic
=== CONT  TestAccCEAnomalyMonitor_Dimensional
=== CONT  TestAccCEAnomalyMonitor_tags
=== CONT  TestAccCEAnomalyMonitor_update
=== CONT  TestAccCEAnomalyMonitor_disappears
--- PASS: TestAccCEAnomalyMonitor_disappears (18.06s)
--- PASS: TestAccCEAnomalyMonitor_basic (23.66s)
--- PASS: TestAccCEAnomalyMonitor_Dimensional (24.27s)
--- PASS: TestAccCEAnomalyMonitor_update (36.22s)
--- PASS: TestAccCEAnomalyMonitor_tags (46.40s)
PASS
ok      github.com/hashicorp/terraform-provider-aws/internal/service/ce 46.539s

Merging! 🚀 Thanks for much for your contribution @brittandeyoung; now on to #25224 for anomaly_subscription coverage.

@zhelding zhelding merged commit 557b1d0 into hashicorp:main Jun 9, 2022
@github-actions github-actions bot added this to the v4.18.0 milestone Jun 9, 2022
@github-actions
Copy link

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

I'm going to lock this pull request 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 related to this change, 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 Jul 10, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
documentation Introduces or discusses updates to documentation. generators Relates to code generators. new-resource Introduces a new resource. provider Pertains to the provider itself, rather than any interaction with AWS. service/ce Issues and PRs that pertain to the ce service. size/XL Managed by automation to categorize the size of a PR. tags Pertains to resource tagging. tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants