From 40bab11251d80963dfb14b747d0531f5905f4cdc Mon Sep 17 00:00:00 2001 From: ryof Date: Mon, 25 Jun 2018 16:17:29 +0900 Subject: [PATCH 1/4] Add Importer to CodeBuild Project resource --- aws/resource_aws_codebuild_project.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/aws/resource_aws_codebuild_project.go b/aws/resource_aws_codebuild_project.go index 4a378ecf048..67d4a7a8b76 100644 --- a/aws/resource_aws_codebuild_project.go +++ b/aws/resource_aws_codebuild_project.go @@ -23,6 +23,9 @@ func resourceAwsCodeBuildProject() *schema.Resource { Read: resourceAwsCodeBuildProjectRead, Update: resourceAwsCodeBuildProjectUpdate, Delete: resourceAwsCodeBuildProjectDelete, + Importer: &schema.ResourceImporter{ + State: schema.ImportStatePassthrough, + }, Schema: map[string]*schema.Schema{ "artifacts": { From 91a6f2e7ca23c6c423bbb1c7ae7ec959762dd8f1 Mon Sep 17 00:00:00 2001 From: ryof Date: Mon, 25 Jun 2018 18:08:38 +0900 Subject: [PATCH 2/4] Add basic import test for CodeBuild Project --- aws/import_aws_codebuild_project_test.go | 31 ++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 aws/import_aws_codebuild_project_test.go diff --git a/aws/import_aws_codebuild_project_test.go b/aws/import_aws_codebuild_project_test.go new file mode 100644 index 00000000000..8068ec96066 --- /dev/null +++ b/aws/import_aws_codebuild_project_test.go @@ -0,0 +1,31 @@ +package aws + +import ( + "testing" + + "github.com/hashicorp/terraform/helper/acctest" + "github.com/hashicorp/terraform/helper/resource" +) + +func TestAWSCodeBuildProject_importBasic(t *testing.T) { + resourceName := "aws_codebuild_project.test" + rName := acctest.RandomWithPrefix("tf-acc-test") + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testAccCheckAWSCodeBuildProjectDestroy, + Steps: []resource.TestStep{ + { + Config: testAccAWSCodeBuildProjectConfig_basic(rName), + }, + { + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, + ImportStateVerifyIgnore: []string{ + "force_destroy", "acl"}, + }, + }, + }) +} From 8705a20f45980dfd9b5074949fc8fc9bebdc757a Mon Sep 17 00:00:00 2001 From: ryof Date: Tue, 26 Jun 2018 00:44:30 +0900 Subject: [PATCH 3/4] Remove unnecessary code from test for CodeBuild import --- aws/import_aws_codebuild_project_test.go | 2 -- 1 file changed, 2 deletions(-) diff --git a/aws/import_aws_codebuild_project_test.go b/aws/import_aws_codebuild_project_test.go index 8068ec96066..7694c4f6683 100644 --- a/aws/import_aws_codebuild_project_test.go +++ b/aws/import_aws_codebuild_project_test.go @@ -23,8 +23,6 @@ func TestAWSCodeBuildProject_importBasic(t *testing.T) { ResourceName: resourceName, ImportState: true, ImportStateVerify: true, - ImportStateVerifyIgnore: []string{ - "force_destroy", "acl"}, }, }, }) From 0cbd700eba93ed1f4f8e37900256ad5a2ad32802 Mon Sep 17 00:00:00 2001 From: ryof Date: Tue, 26 Jun 2018 00:44:56 +0900 Subject: [PATCH 4/4] Add documentation for CodeBuild import functionality --- website/docs/r/codebuild_project.html.markdown | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/website/docs/r/codebuild_project.html.markdown b/website/docs/r/codebuild_project.html.markdown index 5afd8bd94d3..bcd0ee5ebf0 100644 --- a/website/docs/r/codebuild_project.html.markdown +++ b/website/docs/r/codebuild_project.html.markdown @@ -212,3 +212,11 @@ In addition to all arguments above, the following attributes are exported: * `id` - The ARN of the CodeBuild project. * `badge_url` - The URL of the build badge when `badge_enabled` is enabled. + +## Import + +CodeBuild Project can be imported using the `name`, e.g. + +``` +$ terraform import aws_codebuild_project.name project-name +``` \ No newline at end of file