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

A duplicate Security Group rule was found after second apply #25965

Closed
haarchri opened this issue Jul 24, 2022 · 6 comments
Closed

A duplicate Security Group rule was found after second apply #25965

haarchri opened this issue Jul 24, 2022 · 6 comments
Labels
service/vpc Issues and PRs that pertain to the vpc service. stale Old or inactive issues managed by automation, if no further action taken these will get closed.

Comments

@haarchri
Copy link
Contributor

haarchri commented Jul 24, 2022

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue 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 issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

Terraform CLI and Terraform AWS Provider Version

Terraform Version 1.0.5
Provider AWS 3.56.0 also tested 4.22.0 same effect

Affected Resource(s)

  • aws_security_group_rule

Terraform Configuration Files

Please include all Terraform configurations required to reproduce the bug. Bug reports without a functional reproduction may be closed without investigation.

cat main.tf.json
{
    "provider": {
        "aws": {
            "access_key": "xx",
            "region": "eu-central-1",
            "secret_key": "xx",
            "token": "xx"
        }
    },
    "resource": {
        "aws_security_group_rule": {
            "test": {
                "cidr_blocks": [
                    "10.0.0.0/24",
                    "192.168.64.11/32",
                    "192.168.28.11/32",
                    "192.168.192.11/32"
                ],
                "description": "test",
                "from_port": 443,
                "lifecycle": {
                    "prevent_destroy": true
                },
                "protocol": "tcp",
                "security_group_id": "sg-082c7e99a0e4ffcaa",
                "to_port": 443,
                "type": "ingress"
            }
        }
    },
    "terraform": {
        "required_providers": {
            "aws": {
                "source": "hashicorp/aws",
                "version": "3.56.0"
            }
        }
    }
}

cat terraform.tfstate
{
  "version": 4,
  "terraform_version": "1.0.5",
  "serial": 12,
  "lineage": "a1092ece-ceab-4541-9760-47809743155a",
  "outputs": {},
  "resources": []
}

cat terraform.tfstate.backup 
{
  "version": 4,
  "terraform_version": "1.0.5",
  "serial": 11,
  "lineage": "a1092ece-ceab-4541-9760-47809743155a",
  "outputs": {},
  "resources": [
    {
      "mode": "managed",
      "type": "aws_security_group_rule",
      "name": "test",
      "provider": "provider[\"registry.terraform.io/hashicorp/aws\"]",
      "instances": [
        {
          "schema_version": 2,
          "attributes": {
            "cidr_blocks": [
              "10.0.0.0/24",
              "192.168.64.11/32",
              "192.168.28.11/32",
              "192.168.192.11/32"
            ],
            "description": "test",
            "from_port": 443,
            "id": "sgrule-837740959",
            "ipv6_cidr_blocks": [],
            "prefix_list_ids": [],
            "protocol": "tcp",
            "security_group_id": "sg-082c7e99a0e4ffcaa",
            "self": false,
            "source_security_group_id": null,
            "to_port": 443,
            "type": "ingress"
          },
          "sensitive_attributes": [],
          "private": "xxxxx"
        }
      ]
    }
  ]
}

Debug Output

Panic Output

Expected Behavior

Actual Behavior

Steps to Reproduce

  1. terraform plan
  2. terraform apply
  3. terraform plan
  4. terraform apply --> Error
create failed: cannot apply: apply failed: [WARN] A duplicate Security Group rule was found on (sg-082c7e99a0e4ffcaa). This may be
a side effect of a now-fixed Terraform issue causing two security groups with
identical attributes but different source_security_group_ids to overwrite each
other in the state. See https://github.com/hashicorp/terraform/pull/2376 for more
information and instructions for recovery. Error: InvalidPermission.Duplicate: the specified rule "peer: 10.0.0.0/24, TCP, from port: 443, to port: 443, ALLOW" already exists
             status code: 400, request id: a16e81e3-1ea6-47d6-ac08-ec722f2ec2d6: : File name: main.tf.json

Important Factoids

References

  • #0000
@github-actions github-actions bot added needs-triage Waiting for first response or review from a maintainer. service/vpc Issues and PRs that pertain to the vpc service. labels Jul 24, 2022
@justinretzolk
Copy link
Member

Hey @haarchri 👋 Thank you for taking the time to raise this! So that we have all of the necessary information in order to look into this, can you supply the Terraform and AWS Provider versions you're using as well?

@justinretzolk justinretzolk added waiting-response Maintainers are waiting on response from community or contributor. and removed needs-triage Waiting for first response or review from a maintainer. labels Jul 25, 2022
@haarchri
Copy link
Contributor Author

Both in my issue in the files i added

@github-actions github-actions bot removed the waiting-response Maintainers are waiting on response from community or contributor. label Jul 25, 2022
@haarchri
Copy link
Contributor Author

@justinretzolk any idea ?

@haarchri
Copy link
Contributor Author

Looks Like Same issue

#26021

Copy link

Marking this issue as stale due to inactivity. This helps our maintainers find and focus on the active issues. If this issue receives no comments in the next 30 days it will automatically be closed. Maintainers can also remove the stale label.

If this issue was automatically closed and you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thank you!

@github-actions github-actions bot added the stale Old or inactive issues managed by automation, if no further action taken these will get closed. label Jul 31, 2024
@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Aug 30, 2024
Copy link

github-actions bot commented Oct 1, 2024

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 have found a problem that seems similar to this, 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 Oct 1, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
service/vpc Issues and PRs that pertain to the vpc service. stale Old or inactive issues managed by automation, if no further action taken these will get closed.
Projects
None yet
Development

No branches or pull requests

2 participants