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

r/budgets_budget_action - new resource #19554

Merged
merged 10 commits into from
Jun 14, 2021

Conversation

DrFaust92
Copy link
Collaborator

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

Closes #19541

Output from acceptance testing:

$ make testacc TESTARGS='-run=TestAccAWSBudgetsBudgetAction_'
--- PASS: TestAccAWSBudgetsBudgetAction_disappears (49.87s)
--- PASS: TestAccAWSBudgetsBudgetAction_basic (55.76s)

@DrFaust92 DrFaust92 requested a review from a team as a code owner May 27, 2021 19:12
@ghost ghost added size/XXL Managed by automation to categorize the size of a PR. labels May 27, 2021
@github-actions github-actions bot added documentation Introduces or discusses updates to documentation. provider Pertains to the provider itself, rather than any interaction with AWS. service/budgets Issues and PRs that pertain to the budgets service. tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure. labels May 27, 2021
@ewbankkit ewbankkit added the new-resource Introduces a new resource. label Jun 1, 2021
@ewbankkit
Copy link
Contributor

% make testacc TEST=./aws TESTARGS='-run=TestAccAWSBudgetsBudgetAction_'   
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./aws -v -count 1 -parallel 20 -run=TestAccAWSBudgetsBudgetAction_ -timeout 180m
=== RUN   TestAccAWSBudgetsBudgetAction_basic
=== PAUSE TestAccAWSBudgetsBudgetAction_basic
=== RUN   TestAccAWSBudgetsBudgetAction_disappears
=== PAUSE TestAccAWSBudgetsBudgetAction_disappears
=== CONT  TestAccAWSBudgetsBudgetAction_basic
=== CONT  TestAccAWSBudgetsBudgetAction_disappears
    resource_aws_budgets_budget_action_test.go:120: Step 1/1 error: Check failed: Check 2/2 error: Deleting Budget Action failed: ResourceLockedException: This method is not allowed during [ActionStatus: Execution_In_Progress]
--- FAIL: TestAccAWSBudgetsBudgetAction_disappears (15.55s)
=== CONT  TestAccAWSBudgetsBudgetAction_basic
    testing_new.go:63: Error running post-test destroy, there may be dangling resources: exit status 1
        2021/06/08 09:15:13 [DEBUG] Using modified User-Agent: Terraform/0.12.31 HashiCorp-terraform-exec/0.13.3
        
        Error: Deleting Budget Action failed: ResourceLockedException: This method is not allowed during [ActionStatus: Execution_In_Progress]
        
        
--- FAIL: TestAccAWSBudgetsBudgetAction_basic (19.96s)
FAIL
FAIL	github.com/terraform-providers/terraform-provider-aws/aws	23.434s
FAIL
make: *** [testacc] Error 1

When I then view the budget action it's in EXECUTION_FAILURE state and can be deleted:

% aws budgets describe-budget-actions-for-account --account-id 123456789012                                    
{
    "Actions": [
        {
            "ActionId": "69be9bb5-11b0-4a67-aad0-dbd9fcb68e0d",
            "BudgetName": "tf-acc-test-1612764617238458539",
            "NotificationType": "ACTUAL",
            "ActionType": "APPLY_IAM_POLICY",
            "ActionThreshold": {
                "ActionThresholdValue": 100.0,
                "ActionThresholdType": "ABSOLUTE_VALUE"
            },
            "Definition": {
                "IamActionDefinition": {
                    "PolicyArn": "arn:aws:iam::123456789012:policy/tf-acc-test-1612764617238458539",
                    "Roles": [
                        "tf-acc-test-1612764617238458539"
                    ]
                }
            },
            "ExecutionRoleArn": "arn:aws:iam::123456789012:role/tf-acc-test-1612764617238458539",
            "ApprovalModel": "AUTOMATIC",
            "Status": "EXECUTION_FAILURE",
            "Subscribers": [
                {
                    "SubscriptionType": "EMAIL",
                    "Address": "test@test.test"
                }
            ]
        }
    ]
}
% aws budgets delete-budget-action --account-id 123456789012 --budget-name "tf-acc-test-1612764617238458539" --action-id "69be9bb5-11b0-4a67-aad0-dbd9fcb68e0d"
% aws budgets describe-budget-actions-for-account --account-id 123456789012                                                                                    
{
    "Actions": []
}

Some sort of waiter will need to be implemented.
I can't find any state transition documentation though.

@DrFaust92
Copy link
Collaborator Author

Cool, didnt experience this. will take a look regarding delete waiter.

@ewbankkit
Copy link
Contributor

It may be a Create and/or Update waiter that is required.
Thanks.

@DrFaust92
Copy link
Collaborator Author

@ewbankkit added waiters but as you said there are no specific docs on this and i made a guess to what's right

@github-actions github-actions bot added the size/XL Managed by automation to categorize the size of a PR. label Jun 14, 2021
Copy link
Contributor

@ewbankkit ewbankkit left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 🚀.

Commercial
% make testacc TEST=./aws TESTARGS='-run=TestAccAWSBudgetsBudgetAction_'          
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./aws -v -count 1 -parallel 20 -run=TestAccAWSBudgetsBudgetAction_ -timeout 180m
=== RUN   TestAccAWSBudgetsBudgetAction_basic
=== PAUSE TestAccAWSBudgetsBudgetAction_basic
=== RUN   TestAccAWSBudgetsBudgetAction_disappears
=== PAUSE TestAccAWSBudgetsBudgetAction_disappears
=== CONT  TestAccAWSBudgetsBudgetAction_basic
=== CONT  TestAccAWSBudgetsBudgetAction_disappears
--- PASS: TestAccAWSBudgetsBudgetAction_disappears (21.62s)
--- PASS: TestAccAWSBudgetsBudgetAction_basic (55.79s)
PASS
ok  	github.com/terraform-providers/terraform-provider-aws/aws	58.840s
GovCloud
% make testacc TEST=./aws TESTARGS='-run=TestAccAWSBudgetsBudgetAction_'
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./aws -v -count 1 -parallel 20 -run=TestAccAWSBudgetsBudgetAction_ -timeout 180m
=== RUN   TestAccAWSBudgetsBudgetAction_basic
=== PAUSE TestAccAWSBudgetsBudgetAction_basic
=== RUN   TestAccAWSBudgetsBudgetAction_disappears
=== PAUSE TestAccAWSBudgetsBudgetAction_disappears
=== CONT  TestAccAWSBudgetsBudgetAction_basic
=== CONT  TestAccAWSBudgetsBudgetAction_disappears
=== CONT  TestAccAWSBudgetsBudgetAction_basic
    provider_test.go:734: skipping tests; partition aws-us-gov does not support budgets service
=== CONT  TestAccAWSBudgetsBudgetAction_disappears
    provider_test.go:734: skipping tests; partition aws-us-gov does not support budgets service
--- SKIP: TestAccAWSBudgetsBudgetAction_basic (1.54s)
--- SKIP: TestAccAWSBudgetsBudgetAction_disappears (1.54s)
PASS
ok  	github.com/terraform-providers/terraform-provider-aws/aws	4.596s

@ewbankkit
Copy link
Contributor

@DrFaust92 Thanks for the contribution 🎉 👏.
I tweaked the waiters statuses a bit to get the acceptance tests to pass.
As this is a completely new resource I am happy to merge as is and deal with issues when/if they arise.

@ewbankkit ewbankkit merged commit 5785cf6 into hashicorp:main Jun 14, 2021
@github-actions github-actions bot added this to the v3.46.0 milestone Jun 14, 2021
@github-actions
Copy link

This functionality has been released in v3.46.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 18, 2021
@DrFaust92 DrFaust92 deleted the r/budget_action branch February 12, 2022 12:49
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. new-resource Introduces a new resource. provider Pertains to the provider itself, rather than any interaction with AWS. service/budgets Issues and PRs that pertain to the budgets service. size/XL Managed by automation to categorize the size of a PR. size/XXL Managed by automation to categorize the size of a PR. 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.

AWS Budget Actions
2 participants