diff --git a/aws/import_aws_ssm_parameter_test.go b/aws/import_aws_ssm_parameter_test.go new file mode 100644 index 00000000000..fc1a2c79f7a --- /dev/null +++ b/aws/import_aws_ssm_parameter_test.go @@ -0,0 +1,32 @@ +package aws + +import ( + "testing" + + "github.com/hashicorp/terraform/helper/acctest" + "github.com/hashicorp/terraform/helper/resource" +) + +func TestAccAWSSSMParameter_importBasic(t *testing.T) { + resourceName := "aws_ssm_parameter.foo" + randName := acctest.RandString(5) + randValue := acctest.RandString(5) + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testAccCheckAWSSSMParameterDestroy, + Steps: []resource.TestStep{ + { + Config: testAccAWSSSMParameterBasicConfig(randName, randValue), + }, + + { + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, + ImportStateVerifyIgnore: []string{"overwrite"}, + }, + }, + }) +} diff --git a/aws/resource_aws_ssm_parameter.go b/aws/resource_aws_ssm_parameter.go index 39a40883adb..ac0692f6758 100644 --- a/aws/resource_aws_ssm_parameter.go +++ b/aws/resource_aws_ssm_parameter.go @@ -15,6 +15,9 @@ func resourceAwsSsmParameter() *schema.Resource { Read: resourceAwsSsmParameterRead, Update: resourceAwsSsmParameterPut, Delete: resourceAwsSsmParameterDelete, + Importer: &schema.ResourceImporter{ + State: schema.ImportStatePassthrough, + }, Schema: map[string]*schema.Schema{ "name": { @@ -54,7 +57,7 @@ func resourceAwsSsmParameterRead(d *schema.ResourceData, meta interface{}) error paramInput := &ssm.GetParametersInput{ Names: []*string{ - aws.String(d.Get("name").(string)), + aws.String(d.Id()), }, WithDecryption: aws.Bool(true), }