mirror of
https://github.com/opentofu/opentofu.git
synced 2025-01-09 23:54:17 -06:00
2ba1b0fb01
* provider/aws: Populate self in Security Group Rule imports * provider/aws: Add regression test for SG Rule import
57 lines
1.3 KiB
Go
57 lines
1.3 KiB
Go
package aws
|
|
|
|
import (
|
|
"fmt"
|
|
"testing"
|
|
|
|
"github.com/hashicorp/terraform/helper/resource"
|
|
"github.com/hashicorp/terraform/terraform"
|
|
)
|
|
|
|
func TestAccAWSSecurityGroup_importBasic(t *testing.T) {
|
|
checkFn := func(s []*terraform.InstanceState) error {
|
|
// Expect 3: group, 2 rules
|
|
if len(s) != 3 {
|
|
return fmt.Errorf("expected 3 states: %#v", s)
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
resource.Test(t, resource.TestCase{
|
|
PreCheck: func() { testAccPreCheck(t) },
|
|
Providers: testAccProviders,
|
|
CheckDestroy: testAccCheckAWSSecurityGroupDestroy,
|
|
Steps: []resource.TestStep{
|
|
resource.TestStep{
|
|
Config: testAccAWSSecurityGroupConfig,
|
|
},
|
|
|
|
resource.TestStep{
|
|
ResourceName: "aws_security_group.web",
|
|
ImportState: true,
|
|
ImportStateCheck: checkFn,
|
|
},
|
|
},
|
|
})
|
|
}
|
|
|
|
func TestAccAWSSecurityGroup_importSelf(t *testing.T) {
|
|
resource.Test(t, resource.TestCase{
|
|
PreCheck: func() { testAccPreCheck(t) },
|
|
Providers: testAccProviders,
|
|
CheckDestroy: testAccCheckAWSSecurityGroupDestroy,
|
|
Steps: []resource.TestStep{
|
|
resource.TestStep{
|
|
Config: testAccAWSSecurityGroupConfig_importSelf,
|
|
},
|
|
|
|
resource.TestStep{
|
|
ResourceName: "aws_security_group.allow_all",
|
|
ImportState: true,
|
|
ImportStateVerify: true,
|
|
},
|
|
},
|
|
})
|
|
}
|