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

Add nil checks for route table association state #22806

Merged
merged 3 commits into from
Jan 28, 2022

Conversation

blafrisch
Copy link

In aws-iso region the AssociationState isn't set in the Associations for route tables. This caused a nil pointer dereference and an RPC error when refreshing state on an aws_route_table_association resource.

For reference the output from the AWS CLI command aws ec2 describe-route-tables looks like this in AWS us-west-2:

{
    "RouteTables": [
        {
            "Associations": [
                {
                    "AssociationState": {
                        "State": "associated"
                    },
                    "Main": false,
                    "RouteTableAssociationId": "rtbassoc-000000000000000000",
                    "RouteTableId": "rtb-000000000000000000",
                    "SubnetId": "subnet-000000000000000000"
                }
...

And looks like this in an AWS ISO region:

{
    "RouteTables": [
        {
            "Associations": [
                {
                    "Main": false,
                    "RouteTableAssociationId": "rtbassoc-000000000000000000",
                    "RouteTableId": "rtb-000000000000000000",
                    "SubnetId": "subnet-000000000000000000"
                }
...

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

Output from acceptance testing (chosen because of this PR #21710):

% make testacc PKG_NAME=internal/service/ec2 TESTARGS='-run=TestAccEC2RouteTable_basic\|TestAccEC2RouteTableAssociation_Subnet_basic'
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./internal/service/ec2/... -v -count 1 -parallel 20  -run=TestAccEC2RouteTable_basic\|TestAccEC2RouteTableAssociation_Subnet_basic -timeout 180m
=== RUN   TestAccEC2RouteTableAssociation_Subnet_basic
=== PAUSE TestAccEC2RouteTableAssociation_Subnet_basic
=== RUN   TestAccEC2RouteTable_basic
=== PAUSE TestAccEC2RouteTable_basic
=== CONT  TestAccEC2RouteTableAssociation_Subnet_basic
=== CONT  TestAccEC2RouteTable_basic
--- PASS: TestAccEC2RouteTable_basic (65.35s)
--- PASS: TestAccEC2RouteTableAssociation_Subnet_basic (78.33s)
PASS
ok  	github.com/hashicorp/terraform-provider-aws/internal/service/ec2	82.046s

This is my first PR for this project, let me know if there's anything else I should add/update/change. Thank you!

cc: @YakDriver @ewbankkit because of other recent ISO region related changes and context.

In aws-iso region the AssociationState isn't set in the Associations for route tables
@github-actions github-actions bot added service/ec2 Issues and PRs that pertain to the ec2 service. needs-triage Waiting for first response or review from a maintainer. size/XS Managed by automation to categorize the size of a PR. labels Jan 27, 2022
@blafrisch blafrisch marked this pull request as ready for review January 27, 2022 23:18
Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Welcome @blafrisch 👋

It looks like this is your first Pull Request submission to the Terraform AWS Provider! If you haven’t already done so please make sure you have checked out our CONTRIBUTING guide and FAQ to make sure your contribution is adhering to best practice and has all the necessary elements in place for a successful approval.

Also take a look at our FAQ which details how we prioritize Pull Requests for inclusion.

Thanks again, and welcome to the community! 😃

@ewbankkit ewbankkit removed the needs-triage Waiting for first response or review from a maintainer. label Jan 28, 2022
@ewbankkit ewbankkit added waiting-response Maintainers are waiting on response from community or contributor. and removed waiting-response Maintainers are waiting on response from community or contributor. labels Jan 28, 2022
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 🚀.

% make testacc PKG_NAME=internal/service/ec2 TESTARGS='-run=TestAccEC2RouteTableAssociation_\|TestAccEC2MainRouteTableAssociation_' ACCTEST_PARALLELISM=4
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./internal/service/ec2/... -v -count 1 -parallel 4  -run=TestAccEC2RouteTableAssociation_\|TestAccEC2MainRouteTableAssociation_ -timeout 180m
=== RUN   TestAccEC2MainRouteTableAssociation_basic
=== PAUSE TestAccEC2MainRouteTableAssociation_basic
=== RUN   TestAccEC2RouteTableAssociation_Subnet_basic
=== PAUSE TestAccEC2RouteTableAssociation_Subnet_basic
=== RUN   TestAccEC2RouteTableAssociation_Subnet_changeRouteTable
=== PAUSE TestAccEC2RouteTableAssociation_Subnet_changeRouteTable
=== RUN   TestAccEC2RouteTableAssociation_Gateway_basic
=== PAUSE TestAccEC2RouteTableAssociation_Gateway_basic
=== RUN   TestAccEC2RouteTableAssociation_Gateway_changeRouteTable
=== PAUSE TestAccEC2RouteTableAssociation_Gateway_changeRouteTable
=== RUN   TestAccEC2RouteTableAssociation_disappears
=== PAUSE TestAccEC2RouteTableAssociation_disappears
=== CONT  TestAccEC2MainRouteTableAssociation_basic
=== CONT  TestAccEC2RouteTableAssociation_Subnet_changeRouteTable
=== CONT  TestAccEC2RouteTableAssociation_Gateway_basic
=== CONT  TestAccEC2RouteTableAssociation_disappears
--- PASS: TestAccEC2RouteTableAssociation_disappears (35.52s)
=== CONT  TestAccEC2RouteTableAssociation_Gateway_changeRouteTable
--- PASS: TestAccEC2RouteTableAssociation_Gateway_basic (43.95s)
=== CONT  TestAccEC2RouteTableAssociation_Subnet_basic
--- PASS: TestAccEC2RouteTableAssociation_Subnet_changeRouteTable (63.39s)
--- PASS: TestAccEC2MainRouteTableAssociation_basic (63.73s)
--- PASS: TestAccEC2RouteTableAssociation_Subnet_basic (36.79s)
--- PASS: TestAccEC2RouteTableAssociation_Gateway_changeRouteTable (66.05s)
PASS
ok  	github.com/hashicorp/terraform-provider-aws/internal/service/ec2	108.221s

@ewbankkit
Copy link
Contributor

@blafrisch Thanks for the contribution 🎉 👏.

@ewbankkit ewbankkit merged commit d58a414 into hashicorp:main Jan 28, 2022
@github-actions github-actions bot added this to the v3.75.0 milestone Jan 28, 2022
@blafrisch blafrisch deleted the iso_route_table_association_fixes branch January 31, 2022 17:46
@ewbankkit ewbankkit modified the milestones: v3.75.0, v4.0.0 Feb 1, 2022
@github-actions
Copy link

This functionality has been released in v4.0.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 May 21, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
service/ec2 Issues and PRs that pertain to the ec2 service. size/XS Managed by automation to categorize the size of a PR.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants