From 9926bb5a1402dbf7e2e3d7cd1876adffd215db8f Mon Sep 17 00:00:00 2001 From: Atsushi Ishibashi Date: Sat, 24 Feb 2018 01:20:26 +0900 Subject: [PATCH] Support import --- aws/resource_aws_appsync_graphql_api.go | 4 ++++ aws/resource_aws_appsync_graphql_api_test.go | 20 +++++++++++++++++++ .../docs/r/appsync_graphql_api.html.markdown | 8 ++++++++ 3 files changed, 32 insertions(+) diff --git a/aws/resource_aws_appsync_graphql_api.go b/aws/resource_aws_appsync_graphql_api.go index 0031c65b614..5a6b8a1e5fa 100644 --- a/aws/resource_aws_appsync_graphql_api.go +++ b/aws/resource_aws_appsync_graphql_api.go @@ -18,6 +18,10 @@ func resourceAwsAppsyncGraphqlApi() *schema.Resource { Update: resourceAwsAppsyncGraphqlApiUpdate, Delete: resourceAwsAppsyncGraphqlApiDelete, + Importer: &schema.ResourceImporter{ + State: schema.ImportStatePassthrough, + }, + Schema: map[string]*schema.Schema{ "authentication_type": { Type: schema.TypeString, diff --git a/aws/resource_aws_appsync_graphql_api_test.go b/aws/resource_aws_appsync_graphql_api_test.go index 6bd893786c0..f9ed7413c12 100644 --- a/aws/resource_aws_appsync_graphql_api_test.go +++ b/aws/resource_aws_appsync_graphql_api_test.go @@ -62,6 +62,26 @@ func TestAccAWSAppsyncGraphqlApi_cognito(t *testing.T) { }) } +func TestAccAWSAppsyncGraphqlApi_import(t *testing.T) { + resourceName := "aws_appsync_graphql_api.test_apikey" + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testAccCheckAwsAppsyncGraphqlApiDestroy, + Steps: []resource.TestStep{ + resource.TestStep{ + Config: testAccAppsyncGraphqlApiConfig_apikey(acctest.RandString(5)), + }, + resource.TestStep{ + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, + }, + }, + }) +} + func testAccCheckAwsAppsyncGraphqlApiDestroy(s *terraform.State) error { conn := testAccProvider.Meta().(*AWSClient).appsyncconn for _, rs := range s.RootModule().Resources { diff --git a/website/docs/r/appsync_graphql_api.html.markdown b/website/docs/r/appsync_graphql_api.html.markdown index 6cf0918fae1..833f7a95ca6 100644 --- a/website/docs/r/appsync_graphql_api.html.markdown +++ b/website/docs/r/appsync_graphql_api.html.markdown @@ -42,3 +42,11 @@ The following attributes are exported: * `id` - API ID * `arn` - The ARN + +## Import + +AppSync GraphQL API can be imported using the GraphQL API ID, e.g. + +``` +$ terraform import aws_appsync_graphql_api.example 0123456789 +```