what is the best way to solve EntityAlreadyExists error in terraform?

后端 未结 2 1941
遥遥无期
遥遥无期 2021-01-22 11:30

I am using terraform v0.12.6 and I run into many errors like:

Error: Error creating Security Group: InvalidGroup.Duplicate: The security group \'sec         


        
相关标签:
2条回答
  • 2021-01-22 11:40

    Change property "name" to "name_prefix" solved to me, and doesn't duplicate any roles and/or policies.

    0 讨论(0)
  • 2021-01-22 11:50

    Yes. All duplicates should be imported into terraform and each resource's import may be different.

    To import security group sg-903004f8 to terraform resource aws_security_group.elb_sg using your dev profile. You'll need to find the security group id of security-search-populate security group.

    AWS_PROFILE=dev terraform import aws_security_group.elb_sg sg-903004f8
    

    To import IAM role PopulateTaskRole to terraform resource aws_iam_role.developer using your dev profile.

    AWS_PROFILE=dev terraform import aws_iam_role.developer PopulateTaskRole
    

    After these are imported, you can do a targetted terraform plan to see the differences between what's in source controlled terraform and what's upstream in AWS

    AWS_PROFILE=dev terraform plan \
      -target aws_security_group.elb_sg \
      -target aws_iam_role.developer
    
    0 讨论(0)
提交回复
热议问题