providers/aws: key_pair import

This commit is contained in:
Mitchell Hashimoto 2016-05-16 10:13:20 -07:00
parent 4e3488afb8
commit a992860b8d
No known key found for this signature in database
GPG Key ID: 744E147AA52F5B0A
2 changed files with 32 additions and 0 deletions

View File

@ -0,0 +1,29 @@
package aws
import (
"testing"
"github.com/hashicorp/terraform/helper/resource"
)
func TestAccAWSKeyPair_importBasic(t *testing.T) {
resourceName := "aws_key_pair.a_key_pair"
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckAWSKeyPairDestroy,
Steps: []resource.TestStep{
resource.TestStep{
Config: testAccAWSKeyPairConfig,
},
resource.TestStep{
ResourceName: resourceName,
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{"public_key"},
},
},
})
}

View File

@ -18,6 +18,9 @@ func resourceAwsKeyPair() *schema.Resource {
Read: resourceAwsKeyPairRead,
Update: nil,
Delete: resourceAwsKeyPairDelete,
Importer: &schema.ResourceImporter{
State: schema.ImportStatePassthrough,
},
SchemaVersion: 1,
MigrateState: resourceAwsKeyPairMigrateState,