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

resource/aws_cloudwatch_log_subscription_filter: Add support for ResourceNotFound #1414

Merged
merged 2 commits into from
Aug 15, 2017

Conversation

stack72
Copy link
Contributor

@stack72 stack72 commented Aug 15, 2017

Please can both commits be kept here! The first commit was an important change to change the way the acceptance tests work for this resource

Fixes: #1405

% make testacc TEST=./aws TESTARGS='-run=TestAccAWSCloudwatchLogSubscriptionFilter_'
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./aws -v -run=TestAccAWSCloudwatchLogSubscriptionFilter_ -timeout 120m
=== RUN   TestAccAWSCloudwatchLogSubscriptionFilter_basic
--- PASS: TestAccAWSCloudwatchLogSubscriptionFilter_basic (44.98s)
=== RUN   TestAccAWSCloudwatchLogSubscriptionFilter_subscriptionFilterDisappears
--- PASS: TestAccAWSCloudwatchLogSubscriptionFilter_subscriptionFilterDisappears (46.29s)
PASS
ok      github.com/terraform-providers/terraform-provider-aws/aws       91.297s

Before this patch:

% terraform plan
aws_iam_role.iam_for_lambda: Refreshing state... (ID: test_lambdafuntion_iam_role_dev)
aws_cloudwatch_log_group.logs: Refreshing state... (ID: example_lambda_name_dev)
aws_iam_role_policy.test_lambdafunction_iam_policy: Refreshing state... (ID: test_lambdafuntion_iam_role_dev:test_lambdafunction_iam_policy_dev)
aws_lambda_function.test_lambdafunction: Refreshing state... (ID: example_lambda_name_dev)
aws_lambda_permission.allow_cloudwatch_logs: Refreshing state... (ID: AllowExecutionFromCloudWatchLogs)
aws_cloudwatch_log_subscription_filter.test_lambdafunction_logfilter: Refreshing state... (ID: cwlsf-1141377109)
Error refreshing state: 1 error(s) occurred:

* aws_cloudwatch_log_subscription_filter.test_lambdafunction_logfilter: 1 error(s) occurred:

* aws_cloudwatch_log_subscription_filter.test_lambdafunction_logfilter: aws_cloudwatch_log_subscription_filter.test_lambdafunction_logfilter: Error reading SubscriptionFilters for log group example_lambda_name_dev with name prefix test_lambdafunction_logfilter_dev: ResourceNotFoundException: The specified log group does not exist.
	status code: 400, request id: 9fd09281-8181-11e7-9b65-4d3de36b3958

After this patch, we no longer get an issue when planning:

% terraform plan
aws_iam_role.iam_for_lambda: Refreshing state... (ID: test_lambdafuntion_iam_role_dev)
aws_iam_role_policy.test_lambdafunction_iam_policy: Refreshing state... (ID: test_lambdafuntion_iam_role_dev:test_lambdafunction_iam_policy_dev)
aws_lambda_function.test_lambdafunction: Refreshing state... (ID: example_lambda_name_dev)
aws_lambda_permission.allow_cloudwatch_logs: Refreshing state... (ID: AllowExecutionFromCloudWatchLogs)
The Terraform execution plan has been generated and is shown below.
Resources are shown in alphabetical order for quick scanning. Green resources
will be created (or destroyed and then created if an existing resource
exists), yellow resources are being changed in-place, and red resources
will be destroyed. Cyan entries are data sources to be read.

Note: You didn't specify an "-out" parameter to save this plan, so when
"apply" is called, Terraform can't guarantee this is what will execute.

  + aws_cloudwatch_log_group.logs
      arn:               "<computed>"
      name:              "example_lambda_name_dev"
      retention_in_days: "1"

  + aws_cloudwatch_log_subscription_filter.test_lambdafunction_logfilter
      destination_arn: "arn:aws:lambda:us-west-2:187416307283:function:example_lambda_name_dev"
      filter_pattern:  "logtype test"
      log_group_name:  "example_lambda_name_dev"
      name:            "test_lambdafunction_logfilter_dev"
      role_arn:        "<computed>"


Plan: 2 to add, 0 to change, 0 to destroy.

Also cleaned up the acceptance tests to actually test the correct resource rather than a lambda func created as part of the acceptance testing harness

The acceptance tests were actually only testing for the existance of the
lambda func that was created as part of the test harness. This changes
the test to actually check that the subscription filter was created

```
% make testacc TEST=./aws TESTARGS='-run=TestAccAWSCloudwatchLogSubscriptionFilter_basic'
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./aws -v -run=TestAccAWSCloudwatchLogSubscriptionFilter_basic -timeout 120m
=== RUN   TestAccAWSCloudwatchLogSubscriptionFilter_basic
--- PASS: TestAccAWSCloudwatchLogSubscriptionFilter_basic (45.97s)
PASS
ok  	github.com/terraform-providers/terraform-provider-aws/aws	45.995s
```
…urceNotFound

Fixes: hashicorp#1405

```
% make testacc TEST=./aws TESTARGS='-run=TestAccAWSCloudwatchLogSubscriptionFilter_'
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./aws -v -run=TestAccAWSCloudwatchLogSubscriptionFilter_ -timeout 120m
=== RUN   TestAccAWSCloudwatchLogSubscriptionFilter_basic
--- PASS: TestAccAWSCloudwatchLogSubscriptionFilter_basic (44.98s)
=== RUN   TestAccAWSCloudwatchLogSubscriptionFilter_subscriptionFilterDisappears
--- PASS: TestAccAWSCloudwatchLogSubscriptionFilter_subscriptionFilterDisappears (46.29s)
PASS
ok  	github.com/terraform-providers/terraform-provider-aws/aws	91.297s
```
Copy link
Contributor

@grubernaut grubernaut left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!

@grubernaut grubernaut added the bug Addresses a defect in current functionality. label Aug 15, 2017
@grubernaut grubernaut merged commit a942cb2 into hashicorp:master Aug 15, 2017
nbaztec pushed a commit to nbaztec/terraform-provider-aws that referenced this pull request Sep 26, 2017
…sub-1405

resource/aws_cloudwatch_log_subscription_filter: Add support for ResourceNotFound
@ghost
Copy link

ghost commented Apr 11, 2020

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 feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thanks!

@ghost ghost locked and limited conversation to collaborators Apr 11, 2020
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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Refresh fails if aws loggroup is manually deleted
2 participants