From 0bc8809b799f9c2fe2c8844f241d29177d94bae7 Mon Sep 17 00:00:00 2001 From: Kamil Turek Date: Sat, 7 May 2022 18:43:57 +0200 Subject: [PATCH 1/8] Implement new resoruce --- internal/service/location/place_index.go | 224 +++++++++++++++++++++++ 1 file changed, 224 insertions(+) create mode 100644 internal/service/location/place_index.go diff --git a/internal/service/location/place_index.go b/internal/service/location/place_index.go new file mode 100644 index 00000000000..8ca05184950 --- /dev/null +++ b/internal/service/location/place_index.go @@ -0,0 +1,224 @@ +package location + +import ( + "fmt" + "log" + "time" + + "github.com/aws/aws-sdk-go/aws" + "github.com/aws/aws-sdk-go/service/locationservice" + "github.com/hashicorp/aws-sdk-go-base/v2/awsv1shim/v2/tfawserr" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" + "github.com/hashicorp/terraform-provider-aws/internal/conns" +) + +func ResourcePlaceIndex() *schema.Resource { + return &schema.Resource{ + Create: resourcePlaceIndexCreate, + Read: resourcePlaceIndexRead, + Update: resourcePlaceIndexUpdate, + Delete: resourcePlaceIndexDelete, + Importer: &schema.ResourceImporter{ + State: schema.ImportStatePassthrough, + }, + Schema: map[string]*schema.Schema{ + "create_time": { + Type: schema.TypeString, + Computed: true, + }, + "data_source": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + }, + "data_source_configuration": { + Type: schema.TypeList, + Optional: true, + Computed: true, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "intended_use": { + Type: schema.TypeString, + Optional: true, + Default: locationservice.IntendedUseSingleUse, + ValidateFunc: validation.StringInSlice(locationservice.IntendedUse_Values(), false), + }, + }, + }, + }, + "description": { + Type: schema.TypeString, + Optional: true, + ValidateFunc: validation.StringLenBetween(0, 1000), + }, + "index_arn": { + Type: schema.TypeString, + Computed: true, + }, + "index_name": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + ValidateFunc: validation.StringLenBetween(1, 100), + }, + "update_time": { + Type: schema.TypeString, + Computed: true, + }, + }, + } +} + +func resourcePlaceIndexCreate(d *schema.ResourceData, meta interface{}) error { + conn := meta.(*conns.AWSClient).LocationConn + + input := &locationservice.CreatePlaceIndexInput{} + + if v, ok := d.GetOk("data_source"); ok { + input.DataSource = aws.String(v.(string)) + } + + if v, ok := d.GetOk("data_source_configuration"); ok && len(v.([]interface{})) > 0 && v.([]interface{})[0] != nil { + input.DataSourceConfiguration = expandDataSourceConfiguration(v.([]interface{})[0].(map[string]interface{})) + } + + if v, ok := d.GetOk("description"); ok { + input.Description = aws.String(v.(string)) + } + + if v, ok := d.GetOk("index_name"); ok { + input.IndexName = aws.String(v.(string)) + } + + output, err := conn.CreatePlaceIndex(input) + + if err != nil { + return fmt.Errorf("error creating place index: %w", err) + } + + if output == nil { + return fmt.Errorf("error creating place index: empty result") + } + + d.SetId(aws.StringValue(output.IndexName)) + + return resourcePlaceIndexRead(d, meta) +} + +func resourcePlaceIndexRead(d *schema.ResourceData, meta interface{}) error { + conn := meta.(*conns.AWSClient).LocationConn + + input := &locationservice.DescribePlaceIndexInput{ + IndexName: aws.String(d.Id()), + } + + output, err := conn.DescribePlaceIndex(input) + + if !d.IsNewResource() && tfawserr.ErrCodeEquals(err, locationservice.ErrCodeResourceNotFoundException) { + log.Printf("[WARN] Location Service Place Index (%s) not found, removing from state", d.Id()) + d.SetId("") + return nil + } + + if err != nil { + return fmt.Errorf("error getting Location Service Place Index (%s): %w", d.Id(), err) + } + + if output == nil { + return fmt.Errorf("error getting Location Service Place Index (%s): empty response", d.Id()) + } + + d.Set("create_time", aws.TimeValue(output.CreateTime).Format(time.RFC3339)) + d.Set("data_source", output.DataSource) + + if output.DataSourceConfiguration != nil { + d.Set("data_source_configuration", []interface{}{flattenDataSourceConfiguration(output.DataSourceConfiguration)}) + } else { + d.Set("data_source_configuration", nil) + } + + d.Set("description", output.Description) + d.Set("index_arn", output.IndexArn) + d.Set("index_name", output.IndexName) + d.Set("update_time", aws.TimeValue(output.UpdateTime).Format(time.RFC3339)) + + return nil +} + +func resourcePlaceIndexUpdate(d *schema.ResourceData, meta interface{}) error { + conn := meta.(*conns.AWSClient).LocationConn + + if d.HasChanges("data_source_configuration", "description") { + input := &locationservice.UpdatePlaceIndexInput{ + IndexName: aws.String(d.Id()), + // Deprecated but still required by the API + PricingPlan: aws.String(locationservice.PricingPlanRequestBasedUsage), + } + + if v, ok := d.GetOk("data_source_configuration"); ok && len(v.([]interface{})) > 0 && v.([]interface{})[0] != nil { + input.DataSourceConfiguration = expandDataSourceConfiguration(v.([]interface{})[0].(map[string]interface{})) + } + + if v, ok := d.GetOk("description"); ok { + input.Description = aws.String(v.(string)) + } + + _, err := conn.UpdatePlaceIndex(input) + + if err != nil { + return fmt.Errorf("error updating Location Service Place Index (%s): %w", d.Id(), err) + } + } + + return resourcePlaceIndexRead(d, meta) +} + +func resourcePlaceIndexDelete(d *schema.ResourceData, meta interface{}) error { + conn := meta.(*conns.AWSClient).LocationConn + + input := &locationservice.DeletePlaceIndexInput{ + IndexName: aws.String(d.Id()), + } + + _, err := conn.DeletePlaceIndex(input) + + if tfawserr.ErrCodeEquals(err, locationservice.ErrCodeResourceNotFoundException) { + return nil + } + + if err != nil { + return fmt.Errorf("error deleting Location Service Place Index (%s): %w", d.Id(), err) + } + + return nil +} + +func expandDataSourceConfiguration(tfMap map[string]interface{}) *locationservice.DataSourceConfiguration { + if tfMap == nil { + return nil + } + + apiObject := &locationservice.DataSourceConfiguration{} + + if v, ok := tfMap["intended_use"].(string); ok && v != "" { + apiObject.IntendedUse = aws.String(v) + } + + return apiObject +} + +func flattenDataSourceConfiguration(apiObject *locationservice.DataSourceConfiguration) map[string]interface{} { + if apiObject == nil { + return nil + } + + tfMap := map[string]interface{}{} + + if v := apiObject.IntendedUse; v != nil { + tfMap["intended_use"] = aws.StringValue(v) + } + + return tfMap +} From 78a492207ac6fa4bc7b0d28c6f1cb7b02db8cfec Mon Sep 17 00:00:00 2001 From: Kamil Turek Date: Sat, 7 May 2022 18:44:05 +0200 Subject: [PATCH 2/8] Add new resource to the provider --- internal/provider/provider.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/internal/provider/provider.go b/internal/provider/provider.go index 715cd1c9815..4d05e00db21 100644 --- a/internal/provider/provider.go +++ b/internal/provider/provider.go @@ -1610,7 +1610,8 @@ func Provider() *schema.Provider { "aws_lightsail_static_ip": lightsail.ResourceStaticIP(), "aws_lightsail_static_ip_attachment": lightsail.ResourceStaticIPAttachment(), - "aws_location_map": location.ResourceMap(), + "aws_location_map": location.ResourceMap(), + "aws_location_place_index": location.ResourcePlaceIndex(), "aws_macie_member_account_association": macie.ResourceMemberAccountAssociation(), "aws_macie_s3_bucket_association": macie.ResourceS3BucketAssociation(), From 09e04848f9f617645cd16024cae543a6b5835b68 Mon Sep 17 00:00:00 2001 From: Kamil Turek Date: Sat, 7 May 2022 18:44:18 +0200 Subject: [PATCH 3/8] Add acceptance test --- internal/service/location/place_index_test.go | 226 ++++++++++++++++++ 1 file changed, 226 insertions(+) create mode 100644 internal/service/location/place_index_test.go diff --git a/internal/service/location/place_index_test.go b/internal/service/location/place_index_test.go new file mode 100644 index 00000000000..bc1feb6143e --- /dev/null +++ b/internal/service/location/place_index_test.go @@ -0,0 +1,226 @@ +package location_test + +import ( + "fmt" + "testing" + + "github.com/aws/aws-sdk-go/aws" + "github.com/aws/aws-sdk-go/service/locationservice" + "github.com/hashicorp/aws-sdk-go-base/v2/awsv1shim/v2/tfawserr" + sdkacctest "github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" + "github.com/hashicorp/terraform-provider-aws/internal/acctest" + "github.com/hashicorp/terraform-provider-aws/internal/conns" + tflocation "github.com/hashicorp/terraform-provider-aws/internal/service/location" +) + +func TestAccLocationPlaceIndex_basic(t *testing.T) { + rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) + resourceName := "aws_location_place_index.test" + + resource.ParallelTest(t, resource.TestCase{ + PreCheck: func() { acctest.PreCheck(t) }, + ErrorCheck: acctest.ErrorCheck(t, locationservice.EndpointsID), + ProviderFactories: acctest.ProviderFactories, + CheckDestroy: testAccCheckPlaceIndexDestroy, + Steps: []resource.TestStep{ + { + Config: testAccConfigPlaceIndex_basic(rName), + Check: resource.ComposeTestCheckFunc( + testAccCheckPlaceIndexExists(resourceName), + acctest.CheckResourceAttrRFC3339(resourceName, "create_time"), + resource.TestCheckResourceAttr(resourceName, "data_source", "Here"), + resource.TestCheckResourceAttr(resourceName, "data_source_configuration.#", "1"), + resource.TestCheckResourceAttr(resourceName, "data_source_configuration.0.intended_use", locationservice.IntendedUseSingleUse), + resource.TestCheckResourceAttr(resourceName, "description", ""), + acctest.CheckResourceAttrRegionalARN(resourceName, "index_arn", "geo", fmt.Sprintf("place-index/%s", rName)), + resource.TestCheckResourceAttr(resourceName, "index_name", rName), + acctest.CheckResourceAttrRFC3339(resourceName, "update_time"), + ), + }, + { + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, + }, + }, + }) +} + +func TestAccLocationPlaceIndex_disappears(t *testing.T) { + rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) + resourceName := "aws_location_place_index.test" + + resource.ParallelTest(t, resource.TestCase{ + PreCheck: func() { acctest.PreCheck(t) }, + ErrorCheck: acctest.ErrorCheck(t, locationservice.EndpointsID), + ProviderFactories: acctest.ProviderFactories, + CheckDestroy: testAccCheckMapDestroy, + Steps: []resource.TestStep{ + { + Config: testAccConfigPlaceIndex_basic(rName), + Check: resource.ComposeTestCheckFunc( + testAccCheckPlaceIndexExists(resourceName), + acctest.CheckResourceDisappears(acctest.Provider, tflocation.ResourcePlaceIndex(), resourceName), + ), + ExpectNonEmptyPlan: true, + }, + }, + }) +} + +func TestAccLocationPlaceIndex_dataSourceConfigurationIntendedUse(t *testing.T) { + rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) + resourceName := "aws_location_place_index.test" + + resource.ParallelTest(t, resource.TestCase{ + PreCheck: func() { acctest.PreCheck(t) }, + ErrorCheck: acctest.ErrorCheck(t, locationservice.EndpointsID), + ProviderFactories: acctest.ProviderFactories, + CheckDestroy: testAccCheckMapDestroy, + Steps: []resource.TestStep{ + { + Config: testAccConfigPlaceIndex_dataSourceConfigurationIntendedUse(rName, locationservice.IntendedUseSingleUse), + Check: resource.ComposeTestCheckFunc( + testAccCheckPlaceIndexExists(resourceName), + resource.TestCheckResourceAttr(resourceName, "data_source_configuration.#", "1"), + resource.TestCheckResourceAttr(resourceName, "data_source_configuration.0.intended_use", locationservice.IntendedUseSingleUse), + ), + }, + { + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, + }, + { + Config: testAccConfigPlaceIndex_dataSourceConfigurationIntendedUse(rName, locationservice.IntendedUseStorage), + Check: resource.ComposeTestCheckFunc( + testAccCheckPlaceIndexExists(resourceName), + resource.TestCheckResourceAttr(resourceName, "data_source_configuration.#", "1"), + resource.TestCheckResourceAttr(resourceName, "data_source_configuration.0.intended_use", locationservice.IntendedUseStorage), + ), + }, + }, + }) +} + +func TestAccLocationPlaceIndex_description(t *testing.T) { + rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) + resourceName := "aws_location_place_index.test" + + resource.ParallelTest(t, resource.TestCase{ + PreCheck: func() { acctest.PreCheck(t) }, + ErrorCheck: acctest.ErrorCheck(t, locationservice.EndpointsID), + ProviderFactories: acctest.ProviderFactories, + CheckDestroy: testAccCheckPlaceIndexDestroy, + Steps: []resource.TestStep{ + { + Config: testAccConfigPlaceIndex_description(rName, "description1"), + Check: resource.ComposeTestCheckFunc( + testAccCheckPlaceIndexExists(resourceName), + resource.TestCheckResourceAttr(resourceName, "description", "description1"), + ), + }, + { + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, + }, + { + Config: testAccConfigPlaceIndex_description(rName, "description2"), + Check: resource.ComposeTestCheckFunc( + testAccCheckPlaceIndexExists(resourceName), + resource.TestCheckResourceAttr(resourceName, "description", "description2"), + ), + }, + }, + }) +} + +func testAccCheckPlaceIndexDestroy(s *terraform.State) error { + conn := acctest.Provider.Meta().(*conns.AWSClient).LocationConn + + for _, rs := range s.RootModule().Resources { + if rs.Type != "aws_location_place_index" { + continue + } + + input := &locationservice.DescribePlaceIndexInput{ + IndexName: aws.String(rs.Primary.ID), + } + + output, err := conn.DescribePlaceIndex(input) + + if tfawserr.ErrCodeEquals(err, locationservice.ErrCodeResourceNotFoundException) { + continue + } + + if err != nil { + return fmt.Errorf("error getting Location Service Place Index (%s): %w", rs.Primary.ID, err) + } + + if output != nil { + return fmt.Errorf("Location Service Place Index (%s) still exists", rs.Primary.ID) + } + } + + return nil +} + +func testAccCheckPlaceIndexExists(resourceName string) resource.TestCheckFunc { + return func(s *terraform.State) error { + rs, ok := s.RootModule().Resources[resourceName] + + if !ok { + return fmt.Errorf("resource not found: %s", resourceName) + } + + conn := acctest.Provider.Meta().(*conns.AWSClient).LocationConn + + input := &locationservice.DescribePlaceIndexInput{ + IndexName: aws.String(rs.Primary.ID), + } + + _, err := conn.DescribePlaceIndex(input) + + if err != nil { + return fmt.Errorf("error getting Location Service Place Index (%s): %w", rs.Primary.ID, err) + } + + return nil + } +} + +func testAccConfigPlaceIndex_basic(rName string) string { + return fmt.Sprintf(` +resource "aws_location_place_index" "test" { + data_source = "Here" + index_name = %[1]q +} +`, rName) +} + +func testAccConfigPlaceIndex_dataSourceConfigurationIntendedUse(rName, intendedUse string) string { + return fmt.Sprintf(` +resource "aws_location_place_index" "test" { + data_source = "Here" + + data_source_configuration { + intended_use = %[2]q + } + + index_name = %[1]q +} +`, rName, intendedUse) +} + +func testAccConfigPlaceIndex_description(rName, description string) string { + return fmt.Sprintf(` +resource "aws_location_place_index" "test" { + data_source = "Here" + description = %[2]q + index_name = %[1]q +} +`, rName, description) +} From 3b12ea24e1f64d170e9522cdcf58eacfa43c2223 Mon Sep 17 00:00:00 2001 From: Kamil Turek Date: Sat, 7 May 2022 18:57:22 +0200 Subject: [PATCH 4/8] Add tags support --- internal/service/location/place_index.go | 32 +++++++++ internal/service/location/place_index_test.go | 72 +++++++++++++++++++ 2 files changed, 104 insertions(+) diff --git a/internal/service/location/place_index.go b/internal/service/location/place_index.go index 8ca05184950..2f8fcaaf71a 100644 --- a/internal/service/location/place_index.go +++ b/internal/service/location/place_index.go @@ -11,6 +11,8 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" "github.com/hashicorp/terraform-provider-aws/internal/conns" + tftags "github.com/hashicorp/terraform-provider-aws/internal/tags" + "github.com/hashicorp/terraform-provider-aws/internal/verify" ) func ResourcePlaceIndex() *schema.Resource { @@ -67,12 +69,17 @@ func ResourcePlaceIndex() *schema.Resource { Type: schema.TypeString, Computed: true, }, + "tags": tftags.TagsSchema(), + "tags_all": tftags.TagsSchemaComputed(), }, + CustomizeDiff: verify.SetTagsDiff, } } func resourcePlaceIndexCreate(d *schema.ResourceData, meta interface{}) error { conn := meta.(*conns.AWSClient).LocationConn + defaultTagsConfig := meta.(*conns.AWSClient).DefaultTagsConfig + tags := defaultTagsConfig.MergeTags(tftags.New(d.Get("tags").(map[string]interface{}))) input := &locationservice.CreatePlaceIndexInput{} @@ -92,6 +99,10 @@ func resourcePlaceIndexCreate(d *schema.ResourceData, meta interface{}) error { input.IndexName = aws.String(v.(string)) } + if len(tags) > 0 { + input.Tags = Tags(tags.IgnoreAWS()) + } + output, err := conn.CreatePlaceIndex(input) if err != nil { @@ -109,6 +120,8 @@ func resourcePlaceIndexCreate(d *schema.ResourceData, meta interface{}) error { func resourcePlaceIndexRead(d *schema.ResourceData, meta interface{}) error { conn := meta.(*conns.AWSClient).LocationConn + defaultTagsConfig := meta.(*conns.AWSClient).DefaultTagsConfig + ignoreTagsConfig := meta.(*conns.AWSClient).IgnoreTagsConfig input := &locationservice.DescribePlaceIndexInput{ IndexName: aws.String(d.Id()), @@ -142,6 +155,17 @@ func resourcePlaceIndexRead(d *schema.ResourceData, meta interface{}) error { d.Set("description", output.Description) d.Set("index_arn", output.IndexArn) d.Set("index_name", output.IndexName) + + tags := KeyValueTags(output.Tags).IgnoreAWS().IgnoreConfig(ignoreTagsConfig) + + if err := d.Set("tags", tags.RemoveDefaultConfig(defaultTagsConfig).Map()); err != nil { + return fmt.Errorf("error setting tags: %w", err) + } + + if err := d.Set("tags_all", tags.Map()); err != nil { + return fmt.Errorf("error setting tags_all: %w", err) + } + d.Set("update_time", aws.TimeValue(output.UpdateTime).Format(time.RFC3339)) return nil @@ -172,6 +196,14 @@ func resourcePlaceIndexUpdate(d *schema.ResourceData, meta interface{}) error { } } + if d.HasChange("tags_all") { + o, n := d.GetChange("tags_all") + + if err := UpdateTags(conn, d.Get("index_arn").(string), o, n); err != nil { + return fmt.Errorf("error updating tags for Location Service Place Index (%s): %w", d.Id(), err) + } + } + return resourcePlaceIndexRead(d, meta) } diff --git a/internal/service/location/place_index_test.go b/internal/service/location/place_index_test.go index bc1feb6143e..a11df5b9a30 100644 --- a/internal/service/location/place_index_test.go +++ b/internal/service/location/place_index_test.go @@ -36,6 +36,7 @@ func TestAccLocationPlaceIndex_basic(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "description", ""), acctest.CheckResourceAttrRegionalARN(resourceName, "index_arn", "geo", fmt.Sprintf("place-index/%s", rName)), resource.TestCheckResourceAttr(resourceName, "index_name", rName), + resource.TestCheckResourceAttr(resourceName, "tags.%", "0"), acctest.CheckResourceAttrRFC3339(resourceName, "update_time"), ), }, @@ -138,6 +139,50 @@ func TestAccLocationPlaceIndex_description(t *testing.T) { }) } +func TestAccLocationPlaceIndex_tags(t *testing.T) { + rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) + resourceName := "aws_location_place_index.test" + + resource.ParallelTest(t, resource.TestCase{ + PreCheck: func() { acctest.PreCheck(t) }, + ErrorCheck: acctest.ErrorCheck(t, locationservice.EndpointsID), + ProviderFactories: acctest.ProviderFactories, + CheckDestroy: testAccCheckPlaceIndexDestroy, + Steps: []resource.TestStep{ + { + Config: testAccConfigPlaceIndex_tags1(rName, "key1", "value1"), + Check: resource.ComposeTestCheckFunc( + testAccCheckPlaceIndexExists(resourceName), + resource.TestCheckResourceAttr(resourceName, "tags.%", "1"), + resource.TestCheckResourceAttr(resourceName, "tags.key1", "value1"), + ), + }, + { + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, + }, + { + Config: testAccConfigPlaceIndex_tags2(rName, "key1", "value1updated", "key2", "value2"), + Check: resource.ComposeTestCheckFunc( + testAccCheckPlaceIndexExists(resourceName), + resource.TestCheckResourceAttr(resourceName, "tags.%", "2"), + resource.TestCheckResourceAttr(resourceName, "tags.key1", "value1updated"), + resource.TestCheckResourceAttr(resourceName, "tags.key2", "value2"), + ), + }, + { + Config: testAccConfigPlaceIndex_tags1(rName, "key2", "value2"), + Check: resource.ComposeTestCheckFunc( + testAccCheckPlaceIndexExists(resourceName), + resource.TestCheckResourceAttr(resourceName, "tags.%", "1"), + resource.TestCheckResourceAttr(resourceName, "tags.key2", "value2"), + ), + }, + }, + }) +} + func testAccCheckPlaceIndexDestroy(s *terraform.State) error { conn := acctest.Provider.Meta().(*conns.AWSClient).LocationConn @@ -224,3 +269,30 @@ resource "aws_location_place_index" "test" { } `, rName, description) } + +func testAccConfigPlaceIndex_tags1(rName, tagKey1, tagValue1 string) string { + return fmt.Sprintf(` +resource "aws_location_place_index" "test" { + data_source = "Here" + index_name = %[1]q + + tags = { + %[2]q = %[3]q + } +} +`, rName, tagKey1, tagValue1) +} + +func testAccConfigPlaceIndex_tags2(rName, tagKey1, tagValue1, tagKey2, tagValue2 string) string { + return fmt.Sprintf(` +resource "aws_location_place_index" "test" { + data_source = "Here" + index_name = %[1]q + + tags = { + %[2]q = %[3]q + %[4]q = %[5]q + } +} +`, rName, tagKey1, tagValue1, tagKey2, tagValue2) +} From a5e5dd5df583f8d1aee234a8a7b3c2130ed8617f Mon Sep 17 00:00:00 2001 From: Kamil Turek Date: Tue, 17 May 2022 19:05:54 +0200 Subject: [PATCH 5/8] Add documentation page --- .../docs/r/location_place_index.html.markdown | 54 +++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 website/docs/r/location_place_index.html.markdown diff --git a/website/docs/r/location_place_index.html.markdown b/website/docs/r/location_place_index.html.markdown new file mode 100644 index 00000000000..d8d968d897f --- /dev/null +++ b/website/docs/r/location_place_index.html.markdown @@ -0,0 +1,54 @@ +--- +subcategory: "Location" +layout: "aws" +page_title: "AWS: aws_location_place_index" +description: |- + Provides a Location Service Place Index. +--- + +# Resource: aws_location_place_index + +Provides a Location Service Place Index. + +## Example Usage + +```terraform +resource "aws_location_place_index" "example" { + data_source = "Here" + index_name = "example" +} +``` + +## Argument Reference + +The following arguments are required: + +* `data_source` - (Required) Specifies the geospatial data provider for the new place index. +* `index_name` - (Required) The name of the place index resource. + +The following arguments are optional: + +* `data_source_configuration` - (Optional) Configuration block with the data storage option chosen for requesting Places. Detailed below. +* `description` - (Optional) The optional description for the place index resource. +* `tags` - (Optional) Key-value tags for the place index. If configured with a provider [`default_tags` configuration block](https://www.terraform.io/docs/providers/aws/index.html#default_tags-configuration-block) present, tags with matching keys will overwrite those defined at the provider-level. + +### data_source_configuration + +The following arguments are optional: + +* `intended_use` - (Optional) Specifies how the results of an operation will be stored by the caller. Valid values: `SingleUse`, `Storage`. Default: `SingleUse`. + +## Attributes Reference + +* `create_time` - The timestamp for when the place index resource was created in ISO 8601 format. +* `index_arn` - The Amazon Resource Name (ARN) for the place index resource. Used to specify a resource across AWS. +* `tags_all` - A map of tags assigned to the resource, including those inherited from the provider [`default_tags` configuration block](https://www.terraform.io/docs/providers/aws/index.html#default_tags-configuration-block). +* `update_time` - The timestamp for when the place index resource was last update in ISO 8601. + +## Import + +`aws_location_place_index` resources can be imported using the place index name, e.g.: + +``` +$ terraform import aws_location_place_index.example example +``` From 683d833ad4134c368523ce2ac9a4a1449181918f Mon Sep 17 00:00:00 2001 From: Kamil Turek Date: Tue, 17 May 2022 19:08:26 +0200 Subject: [PATCH 6/8] Add changelog --- .changelog/24821.txt | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 .changelog/24821.txt diff --git a/.changelog/24821.txt b/.changelog/24821.txt new file mode 100644 index 00000000000..eca08358af3 --- /dev/null +++ b/.changelog/24821.txt @@ -0,0 +1,3 @@ +```release-note:new-resource +aws_location_place_index +``` From cbcfa4015a9c55e0f29196545c79b3570b35d52a Mon Sep 17 00:00:00 2001 From: Kamil Turek Date: Tue, 17 May 2022 19:11:34 +0200 Subject: [PATCH 7/8] Fix terrafmt issues --- internal/service/location/place_index_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/service/location/place_index_test.go b/internal/service/location/place_index_test.go index a11df5b9a30..ef21e2e6c87 100644 --- a/internal/service/location/place_index_test.go +++ b/internal/service/location/place_index_test.go @@ -287,7 +287,7 @@ func testAccConfigPlaceIndex_tags2(rName, tagKey1, tagValue1, tagKey2, tagValue2 return fmt.Sprintf(` resource "aws_location_place_index" "test" { data_source = "Here" - index_name = %[1]q + index_name = %[1]q tags = { %[2]q = %[3]q From 563e1919f533bd1e571f2466c02b6406e3fc7df9 Mon Sep 17 00:00:00 2001 From: Kamil Turek Date: Tue, 17 May 2022 19:46:15 +0200 Subject: [PATCH 8/8] Add missing byline --- website/docs/r/location_place_index.html.markdown | 2 ++ 1 file changed, 2 insertions(+) diff --git a/website/docs/r/location_place_index.html.markdown b/website/docs/r/location_place_index.html.markdown index d8d968d897f..d2df841349f 100644 --- a/website/docs/r/location_place_index.html.markdown +++ b/website/docs/r/location_place_index.html.markdown @@ -40,6 +40,8 @@ The following arguments are optional: ## Attributes Reference +In addition to all arguments above, the following attributes are exported: + * `create_time` - The timestamp for when the place index resource was created in ISO 8601 format. * `index_arn` - The Amazon Resource Name (ARN) for the place index resource. Used to specify a resource across AWS. * `tags_all` - A map of tags assigned to the resource, including those inherited from the provider [`default_tags` configuration block](https://www.terraform.io/docs/providers/aws/index.html#default_tags-configuration-block).