From c3d363de2918c65d14bc0086c6e45d974745dd1c Mon Sep 17 00:00:00 2001 From: Brian Flad Date: Wed, 6 Mar 2019 13:48:45 -0500 Subject: [PATCH] resource/aws_ssm_patch_baseline: Support resource import Reference: https://github.com/terraform-providers/terraform-provider-aws/issues/7816 Also fixes operating system acceptance test name to follow current project consistency with a separating underscore. Output from acceptance testing: ``` --- PASS: TestAccAWSSSMPatchBaseline_disappears (9.14s) --- PASS: TestAccAWSSSMPatchBaseline_OperatingSystem (18.84s) --- PASS: TestAccAWSSSMPatchBaseline_basic (18.98s) ``` --- aws/resource_aws_ssm_patch_baseline.go | 3 +++ aws/resource_aws_ssm_patch_baseline_test.go | 12 +++++++++++- website/docs/r/ssm_patch_baseline.html.markdown | 8 ++++++++ 3 files changed, 22 insertions(+), 1 deletion(-) diff --git a/aws/resource_aws_ssm_patch_baseline.go b/aws/resource_aws_ssm_patch_baseline.go index 8311437e590..e1e8a9507d3 100644 --- a/aws/resource_aws_ssm_patch_baseline.go +++ b/aws/resource_aws_ssm_patch_baseline.go @@ -35,6 +35,9 @@ func resourceAwsSsmPatchBaseline() *schema.Resource { Read: resourceAwsSsmPatchBaselineRead, Update: resourceAwsSsmPatchBaselineUpdate, Delete: resourceAwsSsmPatchBaselineDelete, + Importer: &schema.ResourceImporter{ + State: schema.ImportStatePassthrough, + }, Schema: map[string]*schema.Schema{ "name": { diff --git a/aws/resource_aws_ssm_patch_baseline_test.go b/aws/resource_aws_ssm_patch_baseline_test.go index 91a215b080c..feffdf693a0 100644 --- a/aws/resource_aws_ssm_patch_baseline_test.go +++ b/aws/resource_aws_ssm_patch_baseline_test.go @@ -35,6 +35,11 @@ func TestAccAWSSSMPatchBaseline_basic(t *testing.T) { "aws_ssm_patch_baseline.foo", "description", "Baseline containing all updates approved for production systems"), ), }, + { + ResourceName: "aws_ssm_patch_baseline.foo", + ImportState: true, + ImportStateVerify: true, + }, { Config: testAccAWSSSMPatchBaselineBasicConfigUpdated(name), Check: resource.ComposeTestCheckFunc( @@ -85,7 +90,7 @@ func TestAccAWSSSMPatchBaseline_disappears(t *testing.T) { }) } -func TestAccAWSSSMPatchBaselineWithOperatingSystem(t *testing.T) { +func TestAccAWSSSMPatchBaseline_OperatingSystem(t *testing.T) { var before, after ssm.PatchBaselineIdentity name := acctest.RandString(10) resource.ParallelTest(t, resource.TestCase{ @@ -111,6 +116,11 @@ func TestAccAWSSSMPatchBaselineWithOperatingSystem(t *testing.T) { "aws_ssm_patch_baseline.foo", "operating_system", "AMAZON_LINUX"), ), }, + { + ResourceName: "aws_ssm_patch_baseline.foo", + ImportState: true, + ImportStateVerify: true, + }, { Config: testAccAWSSSMPatchBaselineConfigWithOperatingSystemUpdated(name), Check: resource.ComposeTestCheckFunc( diff --git a/website/docs/r/ssm_patch_baseline.html.markdown b/website/docs/r/ssm_patch_baseline.html.markdown index 21506aa8d60..de29b7af59e 100644 --- a/website/docs/r/ssm_patch_baseline.html.markdown +++ b/website/docs/r/ssm_patch_baseline.html.markdown @@ -106,3 +106,11 @@ The `approval_rule` block supports: In addition to all arguments above, the following attributes are exported: * `id` - The ID of the patch baseline. + +## Import + +SSM Patch Baselines can be imported by their baseline ID, e.g. + +``` +$ terraform import aws_ssm_patch_baseline.example pb-12345678 +```