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_network_acl_association #1034

Closed
wants to merge 10 commits into from
Closed

New Resource: aws_network_acl_association #1034

wants to merge 10 commits into from

Conversation

takahiro9
Copy link

@radeksimko radeksimko added the new-resource Introduces a new resource. label Jul 3, 2017
@takahiro9
Copy link
Author

Oh sorry. i fix to be success for build.

fix to success go vet .
@takahiro9
Copy link
Author

I think this resource use case is...

if there is restriction to operation of aws resource
ex) if can't create network_acl and can attach network_acl

and i encount to it right now 😭

@grubernaut grubernaut added the enhancement Requests to existing resources that expand the functionality or scope. label Jul 25, 2017
@Ninir
Copy link
Contributor

Ninir commented Aug 17, 2017

Hey @takahiro9

Thanks for opening this.
Do you think you could reword your use-case please? not sure to understand it fully.

Also, what are you trying to achieve that do not work with the actual resources?

@Ninir Ninir added the waiting-response Maintainers are waiting on response from community or contributor. label Aug 17, 2017
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.

Agree fully with @Ninir's comment, went ahead and made a quick review of the PR as-is, in case there's a valid use-case here 😄

d.SetId(naclId)
log.Printf("[INFO] Association ID: %s", d.Id())

return nil
Copy link
Contributor

Choose a reason for hiding this comment

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

Should return resourceAwsNetworkAclAssociationRead(d, meta) here to capture any changes.

subnetId := d.Get("subnet_id").(string)
_, err_association := findNetworkAclAssociation(subnetId, conn)
if err_association != nil {
return fmt.Errorf("Failed to read acl %s with subnet %s: %s", d.Id(), subnetId, err_association)
Copy link
Contributor

Choose a reason for hiding this comment

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

If we fail to read the network acl, set the ID to "", and return nil. This will still register a diff in the Terraform state, as Read happens prior to a plan.

d.SetId(*resp.NewAssociationId)
log.Printf("[INFO] Association ID: %s", d.Id())

return nil
Copy link
Contributor

Choose a reason for hiding this comment

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

Should return Read here as well

@takahiro9
Copy link
Author

thank you to feedback.

went ahead and made a quick review of the PR as-is

oh, thanks to tell me.

Do you think you could reword your use-case please

ok !
・Suppose there is a company 'A' which want to creates a system and a vendor 'B' which creates
・there are aws account for create a system
・company 'A' is admin to aws account
・Company 'A' send to 'B' what iam user credential
・'B' think that use terraform for building infrastructure
・'A' isnt admit that 'B' can create network acl. but ReplaceNetworkAclAssociation admit
・when 'B' want to create nacl. there need 'B' ask to 'A'

i think This resource is effectiveness at this situation. very rare case.

@takahiro9
Copy link
Author

i think this resource that like aws_autoscaling_attachment

@takahiro9
Copy link
Author

please tell me if dont know.
i will be helpful.

sorry for my clumsy english by google translation

Copy link
Contributor

@Ninir Ninir left a comment

Choose a reason for hiding this comment

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

HI @takahiro9

Ok thanks for sharing your use-case. Just left a few comments to address: some cosmetic and some logic work, nothing critical!

Thanks for the work here, and nice first contribution! 👍

Delete: resourceAwsNetworkAclAssociationDelete,

Schema: map[string]*schema.Schema{
"subnet_id": &schema.Schema{
Copy link
Contributor

Choose a reason for hiding this comment

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

Since Go 1.7+, redundant type declaration in composite literal can be safely removed, so:

"subnet_id": &schema.Schema{

can become:

"subnet_id": {

return err
}

// Set the ID and return
Copy link
Contributor

Choose a reason for hiding this comment

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

This comment seems a bit obvious, so would prefer to remove it if you don't mind

AssociationId: association.NetworkAclAssociationId,
NetworkAclId: aws.String(naclId),
}

Copy link
Contributor

Choose a reason for hiding this comment

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

Could you move the log instruction from line 42 here, put it all on one line, and perhaps change it to the below?:

log.Printf("[DEBUG] Creating Network ACL association: %#v", associationOpts)

This would provide all of the parameters for the function, so that we don't need to Printf them :)

subnetId,
naclId)

association, err_association := findNetworkAclAssociation(subnetId, conn)
Copy link
Contributor

Choose a reason for hiding this comment

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

Please prefer camelCase-d variables instead of snake-case-d ones, like errAssociation


association, err_association := findNetworkAclAssociation(subnetId, conn)
if err_association != nil {
return fmt.Errorf("Failed to create acl %s with nacl %s: %s", d.Id(), naclId, err_association)
Copy link
Contributor

Choose a reason for hiding this comment

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

This message is not really accurate. What do you think of rewording it to:

return fmt.Errorf("Failed to find association for subnet %s: %s", subnetId, errAssociation)


func resourceAwsNetworkAclAssociationDelete(d *schema.ResourceData, meta interface{}) error {

log.Printf("[INFO] Do nothing on network acl associatioØ destroy phase: %s", d.Id())
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this method should really do something here, as the association would still exist in the AWS-land.
What do you think of doing something in the idea of: replacing the Network ACL Association created with the default Network ACL, as it is done in the resource_aws_network_acl.go resource?

Also, when you need to destroy something in the TF-land, set the ID to "" and it will be remove from the state, like d.SetId("")

Copy link
Author

Choose a reason for hiding this comment

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

Thank you for comment
I think too

})
}

func testCheckAwsRMNetworkAclAssocExists(name string) resource.TestCheckFunc {
Copy link
Contributor

Choose a reason for hiding this comment

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

This method should check that the association exists, by requesting AWS.
Do you think you could get some inspiration from testAccCheckAWSNetworkAclExists?

website/aws.erb Outdated
@@ -1405,6 +1405,10 @@
<a href="/docs/providers/aws/r/network_acl.html">aws_network_acl</a>
</li>

<li<%= sidebar_current("docs-aws-resource-network-acl-assoc") %>>
Copy link
Contributor

Choose a reason for hiding this comment

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

Please keep the full association word here and line 1409

Provides an network ACL association resource.
---

# aws\_network\_acl\_association
Copy link
Contributor

Choose a reason for hiding this comment

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

antislashes are not needed anymore, it is safe to remove them here

* `id` - The ID of the network ACL
* `network_acl_id` - The ID of the network ACL
* `subnet_id` - The ID of the subnet id

Copy link
Contributor

Choose a reason for hiding this comment

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

Small nitpick but this last line is not needed here 😄

@takahiro9
Copy link
Author

ah. i was late for noticing.

Ok thanks for sharing your use-case

i am happy that can communication !

few comments to address

thank you. it is very informative to me.
please wait for a moment...
I will respond from now.

@radeksimko radeksimko added the size/L Managed by automation to categorize the size of a PR. label Nov 15, 2017
@ColinHebert
Copy link
Contributor

Hey @radeksimko , @takahiro9, what are we missing to merge this in?

@takahiro9
Copy link
Author

thank you.
i do not think.

@radeksimko radeksimko requested a review from Ninir January 12, 2018 10:19
@radeksimko radeksimko added service/ec2 Issues and PRs that pertain to the ec2 service. and removed waiting-response Maintainers are waiting on response from community or contributor. enhancement Requests to existing resources that expand the functionality or scope. labels Jan 12, 2018
@radeksimko radeksimko changed the title Add resource aws network acl association New Resource: aws_network_acl_association Jan 16, 2018
@phillbaker
Copy link

@Ninir @takahiro9 we also have a usecase for this resource: After an initial network ACL is created in a "base" plan, different applications then should be able to look it up (via tags in a data provider) and then create an association relevant to just the subnets relevant to the application.

What can I do to help push this forward? It looks like the outstanding comments have been addressed, however, there is now a merge conflict.

@phillbaker
Copy link

cc @radeksimko. What can I do to help push this forward?

It looks like the outstanding comments have been addressed, however, there is now a merge conflict. Would a new PR that squashes these commits and resolves the merge conflicts help?

@thomaslarsen
Copy link

Any thoughts on when this may be merged in? I have a usecase where the acl is created before the subnet, so I need to associate a new subnet to an already existing acl, which seems to fit with what this resource is achieving.
Any update would be appreciated.

@teamterraform
Copy link

Notification of Recent and Upcoming Changes to Contributions

Thank you for this contribution! There have been a few recent development changes that affect this pull request. We apologize for the inconvenience, especially if there have been long review delays up until now. Please note that this is automated message from an unmonitored account. See the FAQ for additional information on the maintainer team and review prioritization.

If you are unable to complete these updates, please leave a comment for the community and maintainers so someone can potentially continue the work. The maintainers will encourage other contributors to use the existing contribution as the base for additional changes as appropriate. Otherwise, contributions that do not receive updated code or comments from the original contributor may be closed in the future so the maintainers can focus on active items.

For the most up to date information about Terraform AWS Provider development, see the Contributing Guide. Additional technical debt changes can be tracked with the technical-debt label on issues.

As part of updating a pull request with these changes, the most current unit testing and linting will run. These may report issues that were not previously reported.

Action Required: Terraform 0.12 Syntax

Reference: #8950
Reference: #14417

Version 3 and later of the Terraform AWS Provider, which all existing contributions would potentially be added, only supports Terraform 0.12 and later. Certain syntax elements of Terraform 0.11 and earlier show deprecation warnings during runs with Terraform 0.12. Documentation and test configurations, such as those including deprecated string interpolations (some_attribute = "${aws_service_thing.example.id}") should be updated to the newer syntax (some_attribute = aws_service_thing.example.id). Contribution testing will automatically fail on older syntax in the near future. Please see the referenced issues for additional information.

Action Required: Terraform Plugin SDK Version 2

Reference: #14551

The Terraform AWS Provider has been upgraded to the latest version of the Terraform Plugin SDK. Generally, most changes to contributions should only involve updating Go import paths in source code files. Please see the referenced issue for additional information.

Action Required: Removal of website/aws.erb File

Reference: #14712

Any changes to the website/aws.erb file are no longer necessary and should be removed from this contribution to prevent merge issues in the near future when the file is removed from the repository. Please see the referenced issue for additional information.

Upcoming Change of Git Branch Naming

Reference: #14292

Development environments will need their upstream Git branch updated from master to main in the near future. Please see the referenced issue for additional information and scheduling.

Upcoming Change of GitHub Organization

Reference: #14715

This repository will be migrating from https://github.com/terraform-providers/terraform-provider-aws to https://github.com/hashicorp/terraform-provider-aws. No practitioner or developer action is anticipated and most GitHub functionality will automatically redirect to the new location. Go import paths including terraform-providers can remain for now. Please see the referenced issue for additional information and scheduling.

@edmundcraske-bjss
Copy link
Contributor

@ewbankkit Do we know why this has sat around for over 3 years as a concept without any implementation? Seems like there have been a number of issues raised asking for this resource also! #12364 #16660 #17648

@breathingdust breathingdust deleted the branch hashicorp:master November 12, 2021 16:59
@github-actions
Copy link

github-actions bot commented Jun 9, 2022

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 Jun 9, 2022
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/ec2 Issues and PRs that pertain to the ec2 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.

10 participants