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_wafregional_web_acl_association #3755

Merged

Conversation

pvanbuijtene
Copy link
Contributor

Trying to help a bit to finish the WAF Regional PRs, this is the result of the split up of #3199

Related PRs: #1047 hashicorp/terraform#13712

Thanks to the contributors: @yusukegoto @DennyLoko @BSick7

@ghost ghost added the size/L Managed by automation to categorize the size of a PR. label Mar 12, 2018
@radeksimko radeksimko added service/waf Issues and PRs that pertain to the waf service. new-resource Introduces a new resource. labels Mar 13, 2018
@radeksimko
Copy link
Member

I'll put this one on hold until feedback in #3756 and #3754 is addressed and PRs merged 😉

@radeksimko radeksimko added this to the v1.12.0 milestone Mar 15, 2018
Copy link
Member

@radeksimko radeksimko left a comment

Choose a reason for hiding this comment

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

Thanks for this PR too, I left you some initial comments and I assume the branch will need rebasing.

If I understand correctly, the relationship between Web ACL & ALB is 1-to-N (1 Web ACL can be assigned to N ALBs). Do you mind exercising this in an acceptance test too? i.e. add a test which assigns a single ACL to two different ALBs?

_, err = conn.AssociateWebACL(params)
if err != nil {
if awsErr, ok := err.(awserr.Error); ok {
if awsErr.Code() == "WAFUnavailableEntityException" {
Copy link
Member

Choose a reason for hiding this comment

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

Do you mind replacing this with a helper?

if isAWSErr(err, wafregional.ErrCodeWAFUnavailableEntityException, "") {

}
if !found {
// It seems it doesn't exist anymore, so clear the ID
d.SetId("")
Copy link
Member

Choose a reason for hiding this comment

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

It's a convention to log a WARN message in these cases, before we wipe the resource from state. Do you mind adding it?


func resourceAwsWafRegionalWebAclAssociationUpdate(d *schema.ResourceData, meta interface{}) error {
return resourceAwsWafRegionalWebAclAssociationRead(d, meta)
}
Copy link
Member

Choose a reason for hiding this comment

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

If update isn't actually implemented I think we should just mark web_acl_id as ForceNew too and remove the Update altogether, otherwise we'd pretend that it's being updated when it's not.

continue
}

web_acl_id, resource_arn := resourceAwsWafRegionalWebAclAssociationParseId(rs.Primary.ID)
Copy link
Member

Choose a reason for hiding this comment

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

Nitpick: it is a convention in Go generally to follow camelCase instead of under_score for variables.

type = "COUNT"
}
priority = 100
rule_id = "${aws_wafregional_rule.foo.id}"
Copy link
Member

Choose a reason for hiding this comment

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

Nitpick: Do you mind fixing the indentation here?

}

resource "aws_wafregional_web_acl_association" "foo" {
depends_on = ["aws_alb.foo", "aws_wafregional_web_acl.foo"]
Copy link
Member

Choose a reason for hiding this comment

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

The depends_on is redundant here as the relationship is already defined by the references below. Do you mind removing it?

resource "aws_wafregional_ipset" "ipset" {
name = "tfIPSet"

ip_set_descriptors {
Copy link
Member

Choose a reason for hiding this comment

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

I think this should be ip_set_descriptor (singular)

name = "tfWAFRule"
metric_name = "tfWAFRule"

predicates {
Copy link
Member

Choose a reason for hiding this comment

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

I think this should be predicate (singular)

type = "ALLOW"
}

rules {
Copy link
Member

Choose a reason for hiding this comment

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

I think this should be rule (singular)

}

resource "aws_alb" "alb" {
subnets = ["${aws_subnet.foo.id}", "${aws_subnet.bar.id}"]
Copy link
Member

Choose a reason for hiding this comment

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

We'll either need to make this ALB internal, so it doesn't need IGW, or add an IGW to the VPC.
Also we'll need to use aws_availability_zones data source to ensure that each subnet is created in a different AZ, otherwise we might end up with both subnets in the same AZ, which will effectively cause the ALB creation to fail (it requires subnets in two different AZs).

@radeksimko radeksimko added the waiting-response Maintainers are waiting on response from community or contributor. label Mar 21, 2018
@pvanbuijtene pvanbuijtene force-pushed the wafregional-web-acl-association branch from d51f274 to b74a955 Compare March 22, 2018 20:15
@ghost ghost added the size/L Managed by automation to categorize the size of a PR. label Mar 22, 2018
@pvanbuijtene
Copy link
Contributor Author

@radeksimko the finish is near ;) ... ready for review

@radeksimko radeksimko removed the waiting-response Maintainers are waiting on response from community or contributor. label Mar 22, 2018
@ghost ghost added the size/L Managed by automation to categorize the size of a PR. label Mar 23, 2018
Copy link
Member

@radeksimko radeksimko left a comment

Choose a reason for hiding this comment

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

Thanks, LGTM now.

I just reordered the docs sidebar to put in in alphabetical order and fixed some indentation.

Thanks to everyone involved. This will be part of the upcoming release.

@radeksimko radeksimko merged commit ef5be04 into hashicorp:master Mar 23, 2018
@bflad
Copy link
Contributor

bflad commented Mar 23, 2018

This has been released in version 1.12.0 of the AWS provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading.

@ghost
Copy link

ghost commented Apr 7, 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 7, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
new-resource Introduces a new resource. service/waf Issues and PRs that pertain to the waf service. size/L Managed by automation to categorize the size of a PR.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants