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/wafv2_web_acl_logging_configuration: new resource #13892

Merged
merged 14 commits into from Jun 25, 2020

Conversation

anGie44
Copy link
Contributor

@anGie44 anGie44 commented Jun 23, 2020

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 #13855

Release note for CHANGELOG:

resource/wafv2_web_acl_logging_configuration: new resource to start logging from a web_acl

Output from acceptance testing:

--- PASS: TestAccAwsWafv2WebACLLoggingConfiguration_basic (129.41s)
--- PASS: TestAccAwsWafv2WebACLLoggingConfiguration_webACLDisappears (133.18s)
--- PASS: TestAccAwsWafv2WebACLLoggingConfiguration_disappears (167.98s)
--- PASS: TestAccAwsWafv2WebACLLoggingConfiguration_update (221.72s)
--- PASS: TestAccAwsWafv2WebACLLoggingConfiguration_changeResourceARNForceNew (239.38s)
--- PASS: TestAccAwsWafv2WebACLLoggingConfiguration_changeLogDestinationConfigsForceNew (225.34s)

@ghost ghost added size/XL Managed by automation to categorize the size of a PR. provider Pertains to the provider itself, rather than any interaction with AWS. service/wafv2 Issues and PRs that pertain to the wafv2 service. tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure. documentation Introduces or discusses updates to documentation. labels Jun 23, 2020
@anGie44 anGie44 marked this pull request as ready for review June 23, 2020 22:29
@anGie44 anGie44 requested a review from a team June 23, 2020 22:29
@bflad bflad self-assigned this Jun 23, 2020
@bflad bflad added the new-resource Introduces a new resource. label Jun 23, 2020
Copy link
Member

@bflad bflad left a comment

Choose a reason for hiding this comment

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

Overall this is looking pretty great, just a few minor things and should be good to go!

Output from acceptance testing:

--- PASS: TestAccAwsWafv2WebACLLoggingConfiguration_basic (127.73s)
--- PASS: TestAccAwsWafv2WebACLLoggingConfiguration_disappears (165.43s)
--- PASS: TestAccAwsWafv2WebACLLoggingConfiguration_changeResourceArnForceNew (167.43s)
--- FAIL: TestAccAwsWafv2WebACLLoggingConfiguration_changeLogDestinationConfigsForceNew (184.56s)
--- PASS: TestAccAwsWafv2WebACLLoggingConfiguration_update (194.59s)

I'm having trouble getting that failing test to pass, is there something special that needs to be done?

--- FAIL: TestAccAwsWafv2WebACLLoggingConfiguration_changeLogDestinationConfigsForceNew (157.92s)
testing.go:684: Step 1 error: errors during apply:
Error: WAFLimitsExceededException: AWS WAF couldn’t perform the operation because you exceeded your resource limit.

aws/resource_aws_wafv2_web_acl_logging_configuration.go Outdated Show resolved Hide resolved
aws/resource_aws_wafv2_web_acl_logging_configuration.go Outdated Show resolved Hide resolved
aws/resource_aws_wafv2_web_acl_logging_configuration.go Outdated Show resolved Hide resolved
aws/resource_aws_wafv2_web_acl_logging_configuration.go Outdated Show resolved Hide resolved
aws/resource_aws_wafv2_web_acl_logging_configuration.go Outdated Show resolved Hide resolved
Comment on lines 342 to 343
"Resource": "arn:aws:iam::*:role/aws-service-role/wafv2.amazonaws.com/AWSServiceRoleForWAFV2Logging",
"Condition": {"StringLike": {"iam:AWSServiceName": "wafv2.amazonaws.com"}}
Copy link
Member

Choose a reason for hiding this comment

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

Nit: To allow this configuration to work across AWS partitions, this should utilize the aws_partition data source, e.g.

data "aws_partition" "current" {}
# ...
	  "Resource": "arn:${data.aws_partition.current.partition}:iam::*:role/aws-service-role/wafv2.${data.aws_partition.current.dns_suffix}/AWSServiceRoleForWAFV2Logging",
	  "Condition": {"StringLike": {"iam:AWSServiceName": "wafv2.${data.aws_partition.current.dns_suffix}"}}

Copy link
Member

Choose a reason for hiding this comment

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

Looks like this might have auto-resolved -- see the aws_partition data source but not it being used here. 😄

Copy link
Contributor Author

Choose a reason for hiding this comment

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

oh wow totally missed where it was used -- i'll add just in case

@anGie44
Copy link
Contributor Author

anGie44 commented Jun 24, 2020

I'm having trouble getting that failing test to pass, is there something special that needs to be done?

hmm it might be that a WebACL can actually only have 1 logging destination even though the docs suggest you could provide multiple kinesis ARNs 🤔 https://docs.aws.amazon.com/waf/latest/APIReference/API_LoggingConfiguration.html#WAF-Type-LoggingConfiguration-LogDestinationConfigs .. I thought maybe it was the number of requests (like 1 PutLoggingConfiguration per kinesis destination), but even in the AWS console (the CLI as well), it only allows you to select one kinesis stream from the dropdown when editing the logging details of the web ACL. unless this is something supported if a quota increase is requested?

I've left the schema as-is to keep inline w/AWS but noted the limitation in the docs (also added the question in the AWS sdk repo in case I'm missing something aws/aws-sdk-go#3390).

@anGie44 anGie44 requested a review from bflad June 24, 2020 17:33
Copy link
Member

@bflad bflad left a comment

Choose a reason for hiding this comment

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

Looks like the concurrent testing is finding a locking issue with the PutLoggingConfiguration API. We should add automatic retrying logic in aws/config.go to handle this situation.

First run:

--- FAIL: TestAccAwsWafv2WebACLLoggingConfiguration_changeResourceARNForceNew (77.91s)
testing.go:684: Step 0 error: errors during apply:
Error: error putting WAFv2 Logging Configuration for resource (arn:aws:wafv2:us-west-2:*******:regional/webacl/tf-acc-test-5540436077421452665/941ff8df-a73e-42a1-95d8-d0e49f20af54): WAFServiceLinkedRoleErrorException: AWS WAF couldn’t obtain a service-linked role (SLR) lock for your operation because the lock was in use. Retry your operation.

Next run:

--- FAIL: TestAccAwsWafv2WebACLLoggingConfiguration_changeLogDestinationConfigsForceNew (104.71s)
testing.go:684: Step 0 error: errors during apply:
Error: error putting WAFv2 Logging Configuration for resource (arn:aws:wafv2:us-west-2:*******:regional/webacl/tf-acc-test-231078216715910326/d783a407-2d2f-4568-b7f1-6254c7cf4696): WAFServiceLinkedRoleErrorException: AWS WAF couldn’t obtain a service-linked role (SLR) lock for your operation because the lock was in use. Retry your operation.

e.g. something like this near the others:

		if isAWSErr(r.Error, wafv2.ErrCodeWAFServiceLinkedRoleErrorException, "Retry your operation") {
			r.Retryable = aws.Bool(true)
		}

Otherwise, looking good 👍

Comment on lines 342 to 343
"Resource": "arn:aws:iam::*:role/aws-service-role/wafv2.amazonaws.com/AWSServiceRoleForWAFV2Logging",
"Condition": {"StringLike": {"iam:AWSServiceName": "wafv2.amazonaws.com"}}
Copy link
Member

Choose a reason for hiding this comment

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

Looks like this might have auto-resolved -- see the aws_partition data source but not it being used here. 😄

@itsSaad
Copy link

itsSaad commented Jun 25, 2020

@anGie44 Will this be able to go out with 2.68.0 release?

@bflad
Copy link
Member

bflad commented Jun 25, 2020

@itsSaad this will be released when it has a maintainer approved review, which is currently in progress. I would anticipate that it will likely be with today's release, but it may be next week.

Copy link
Member

@bflad bflad left a comment

Choose a reason for hiding this comment

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

LGTM 🚀

Output from acceptance testing:

--- PASS: TestAccAwsWafv2WebACLLoggingConfiguration_webACLDisappears (114.82s)
--- PASS: TestAccAwsWafv2WebACLLoggingConfiguration_basic (139.50s)
--- PASS: TestAccAwsWafv2WebACLLoggingConfiguration_disappears (150.11s)
--- PASS: TestAccAwsWafv2WebACLLoggingConfiguration_update (188.56s)
--- PASS: TestAccAwsWafv2WebACLLoggingConfiguration_changeResourceARNForceNew (214.90s)
--- PASS: TestAccAwsWafv2WebACLLoggingConfiguration_changeLogDestinationConfigsForceNew (235.59s)

@anGie44 anGie44 merged commit 62468b9 into master Jun 25, 2020
@anGie44 anGie44 deleted the f-wafv2-logging-config branch June 25, 2020 14:28
@anGie44 anGie44 added this to the v2.68.0 milestone Jun 25, 2020
anGie44 added a commit that referenced this pull request Jun 25, 2020
c4po added a commit to c4po/terraform-provider-aws that referenced this pull request Jun 25, 2020
* origin/master: (59 commits)
  Update CHANGELOG for hashicorp#13935
  resource/aws_batch_compute_environment: Remove resource from Terraform state when not found instead of returning error (hashicorp#13935)
  resource/aws_dynamodb_table: Return error instead of panic on empty CreateTable response (hashicorp#13925)
  Update CHANGELOG for hashicorp#13918
  New Data Source: aws_efs_access_points (hashicorp#13918)
  tests/resource/aws_instance: Ensure sweeper has dependencies on resources that manage EC2 Instances (hashicorp#13917)
  Update CHANGELOG for hashicorp#13937
  Update CHANGELOG for hashicorp#5448
  resource/aws_cloudtrail: Handle single event selector in cloudtrail with non-default read_write_type (hashicorp#5448)
  Update CHANGELOG for hashicorp#13892
  correct retry message to match in error handling
  correct import resource name
  accept empty string in volume_type validation
  Update CHANGELOG for hashicorp#4855
  resource/aws_batch_compute_environment: Support fully optional desired_vcpus and wait for updates
  add retry error handling for SLR
  remove unused WebACL resource name in disappears test
  reference current AWS partition in iam role policy stmt
  remove duplicated disappears test step
  Update CHANGELOG for hashicorp#13926
  ...
@ghost
Copy link

ghost commented Jun 26, 2020

This has been released in version 2.68.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 for triage. Thanks!

@ghost
Copy link

ghost commented Jul 25, 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!

@hashicorp hashicorp locked and limited conversation to collaborators Jul 25, 2020
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/wafv2 Issues and PRs that pertain to the wafv2 service. size/XL 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.

A Resource to put logging configuration for a wafv2 webacl
3 participants