From bc692d06426f3c55b08d4401975246e793711cdb Mon Sep 17 00:00:00 2001 From: Dirk Avery Date: Tue, 15 Jun 2021 13:54:40 -0400 Subject: [PATCH 01/12] i/servicecat: Add statuser --- aws/internal/service/servicecatalog/id.go | 4 ++ .../service/servicecatalog/waiter/status.go | 44 +++++++++++++++++++ 2 files changed, 48 insertions(+) diff --git a/aws/internal/service/servicecatalog/id.go b/aws/internal/service/servicecatalog/id.go index 3eb0a6f8a41..a15f1a759a2 100644 --- a/aws/internal/service/servicecatalog/id.go +++ b/aws/internal/service/servicecatalog/id.go @@ -87,3 +87,7 @@ func PrincipalPortfolioAssociationParseID(id string) (string, string, string, er func PrincipalPortfolioAssociationID(acceptLanguage, principalARN, portfolioID string) string { return strings.Join([]string{acceptLanguage, principalARN, portfolioID}, ",") } + +func PortfolioConstraintsID(acceptLanguage, portfolioID, productID string) string { + return strings.Join([]string{acceptLanguage, portfolioID, productID}, ":") +} diff --git a/aws/internal/service/servicecatalog/waiter/status.go b/aws/internal/service/servicecatalog/waiter/status.go index d1f39a9489a..7f4dfe87241 100644 --- a/aws/internal/service/servicecatalog/waiter/status.go +++ b/aws/internal/service/servicecatalog/waiter/status.go @@ -417,3 +417,47 @@ func RecordStatus(conn *servicecatalog.ServiceCatalog, acceptLanguage, id string return output, aws.StringValue(output.RecordDetail.Status), err } } + +func PortfolioConstraintsStatus(conn *servicecatalog.ServiceCatalog, acceptLanguage, portfolioID, productID string) resource.StateRefreshFunc { + return func() (interface{}, string, error) { + input := &servicecatalog.ListConstraintsForPortfolioInput{ + PortfolioId: aws.String(portfolioID), + } + + if acceptLanguage != "" { + input.AcceptLanguage = aws.String(acceptLanguage) + } + + if productID != "" { + input.ProductId = aws.String(productID) + } + + var output []*servicecatalog.ConstraintDetail + + err := conn.ListConstraintsForPortfolioPages(input, func(page *servicecatalog.ListConstraintsForPortfolioOutput, lastPage bool) bool { + if page == nil { + return !lastPage + } + + for _, deet := range page.ConstraintDetails { + if deet == nil { + continue + } + + output = append(output, deet) + } + + return !lastPage + }) + + if tfawserr.ErrCodeEquals(err, servicecatalog.ErrCodeResourceNotFoundException) { + return nil, StatusNotFound, nil + } + + if err != nil { + return nil, servicecatalog.StatusFailed, err + } + + return output, servicecatalog.StatusAvailable, err + } +} From 819e2900dfa5ac049dec3d6374c97316ac4a2fce Mon Sep 17 00:00:00 2001 From: Dirk Avery Date: Tue, 15 Jun 2021 13:55:09 -0400 Subject: [PATCH 02/12] i/servicecat: Add waiter --- .../service/servicecatalog/waiter/waiter.go | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/aws/internal/service/servicecatalog/waiter/waiter.go b/aws/internal/service/servicecatalog/waiter/waiter.go index ea2cc78fd43..0e878168594 100644 --- a/aws/internal/service/servicecatalog/waiter/waiter.go +++ b/aws/internal/service/servicecatalog/waiter/waiter.go @@ -48,6 +48,8 @@ const ( RecordReadyTimeout = 3 * time.Minute + PortfolioConstraintsReadyTimeout = 3 * time.Minute + MinTimeout = 2 * time.Second NotFoundChecks = 5 ContinuousTargetOccurrence = 2 @@ -540,3 +542,20 @@ func RecordReady(conn *servicecatalog.ServiceCatalog, acceptLanguage, id string) return nil, err } + +func PortfolioConstraintsReady(conn *servicecatalog.ServiceCatalog, acceptLanguage, portfolioID, productID string) ([]*servicecatalog.ConstraintDetail, error) { + stateConf := &resource.StateChangeConf{ + Pending: []string{StatusNotFound}, + Target: []string{servicecatalog.StatusAvailable}, + Refresh: PortfolioConstraintsStatus(conn, acceptLanguage, portfolioID, productID), + Timeout: PortfolioConstraintsReadyTimeout, + } + + outputRaw, err := stateConf.WaitForState() + + if output, ok := outputRaw.([]*servicecatalog.ConstraintDetail); ok { + return output, err + } + + return nil, err +} From 220dd5424eab1478dd36104698742aa2604fe909 Mon Sep 17 00:00:00 2001 From: Dirk Avery Date: Tue, 15 Jun 2021 13:55:33 -0400 Subject: [PATCH 03/12] provider: Add new data source --- aws/provider.go | 1 + 1 file changed, 1 insertion(+) diff --git a/aws/provider.go b/aws/provider.go index e71d04dfcf1..f8c6a4179ed 100644 --- a/aws/provider.go +++ b/aws/provider.go @@ -393,6 +393,7 @@ func Provider() *schema.Provider { "aws_secretsmanager_secret_version": dataSourceAwsSecretsManagerSecretVersion(), "aws_servicecatalog_constraint": dataSourceAwsServiceCatalogConstraint(), "aws_servicecatalog_launch_paths": dataSourceAwsServiceCatalogLaunchPaths(), + "aws_servicecatalog_portfolio_constraints": dataSourceAwsServiceCatalogPortfolioConstraints(), "aws_servicecatalog_portfolio": dataSourceAwsServiceCatalogPortfolio(), "aws_servicecatalog_product": dataSourceAwsServiceCatalogProduct(), "aws_servicequotas_service": dataSourceAwsServiceQuotasService(), From 12d2b98f82ee4f05e3026831d1079ee9af57f930 Mon Sep 17 00:00:00 2001 From: Dirk Avery Date: Tue, 15 Jun 2021 13:56:21 -0400 Subject: [PATCH 04/12] docs/d/servicecat_port_contraints: New data source --- ...atalog_portfolio_constraints.html.markdown | 45 +++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 website/docs/d/servicecatalog_portfolio_constraints.html.markdown diff --git a/website/docs/d/servicecatalog_portfolio_constraints.html.markdown b/website/docs/d/servicecatalog_portfolio_constraints.html.markdown new file mode 100644 index 00000000000..611a6e148c5 --- /dev/null +++ b/website/docs/d/servicecatalog_portfolio_constraints.html.markdown @@ -0,0 +1,45 @@ +--- +subcategory: "Service Catalog" +layout: "aws" +page_title: "AWS: aws_servicecatalog_portfolio_constraints" +description: |- + Provides information on Service Catalog Portfolio Constraints +--- + +# Data source: aws_servicecatalog_portfolio_constraints + +Provides information on Service Catalog Portfolio Constraints. + +## Example Usage + +### Basic Usage + +```terraform +data "aws_servicecatalog_portfolio_constraints" "example" { + portfolio_id = "port-3lli3b3an" +} +``` + +## Argument Reference + +The following arguments are required: + +* `portfolio_id` - Portfolio identifier. + +The following arguments are optional: + +* `accept_language` - (Optional) Language code. Valid values: `en` (English), `jp` (Japanese), `zh` (Chinese). Default value is `en`. +* `product_id` - (Optional) Product identifier. + +## Attributes Reference + +In addition to all arguments above, the following attributes are exported: + +* `details` - List of information about the constraints. See details below. + +### details + +* `constraint_id` - Identifier of the constraint. +* `description` - Description of the constraint. +* `product_id` - Identifier of the product the constraint applies to. A constraint applies to a specific instance of a product within a certain portfolio. +* `type` - Type of constraint. Valid values are `LAUNCH`, `NOTIFICATION`, `STACKSET`, and `TEMPLATE`. From c6d4a185ba26626245f25f8f63abe9ae2d8f83c8 Mon Sep 17 00:00:00 2001 From: Dirk Avery Date: Tue, 15 Jun 2021 13:56:59 -0400 Subject: [PATCH 05/12] d/servicecat_port_contraints: New data source --- ...ws_servicecatalog_portfolio_constraints.go | 137 ++++++++++++++++++ 1 file changed, 137 insertions(+) create mode 100644 aws/data_source_aws_servicecatalog_portfolio_constraints.go diff --git a/aws/data_source_aws_servicecatalog_portfolio_constraints.go b/aws/data_source_aws_servicecatalog_portfolio_constraints.go new file mode 100644 index 00000000000..4e5e31e7deb --- /dev/null +++ b/aws/data_source_aws_servicecatalog_portfolio_constraints.go @@ -0,0 +1,137 @@ +package aws + +import ( + "fmt" + + "github.com/aws/aws-sdk-go/aws" + "github.com/aws/aws-sdk-go/service/servicecatalog" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" + tfservicecatalog "github.com/terraform-providers/terraform-provider-aws/aws/internal/service/servicecatalog" + "github.com/terraform-providers/terraform-provider-aws/aws/internal/service/servicecatalog/waiter" +) + +func dataSourceAwsServiceCatalogPortfolioConstraints() *schema.Resource { + return &schema.Resource{ + Read: dataSourceAwsServiceCatalogPortfolioConstraintsRead, + + Schema: map[string]*schema.Schema{ + "accept_language": { + Type: schema.TypeString, + Optional: true, + Default: "en", + ValidateFunc: validation.StringInSlice(tfservicecatalog.AcceptLanguage_Values(), false), + }, + "details": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "constraint_id": { + Type: schema.TypeString, + Computed: true, + }, + "description": { + Type: schema.TypeString, + Computed: true, + }, + "owner": { + Type: schema.TypeString, + Computed: true, + }, + "product_id": { + Type: schema.TypeString, + Computed: true, + }, + "type": { + Type: schema.TypeString, + Computed: true, + }, + }, + }, + }, + "portfolio_id": { + Type: schema.TypeString, + Required: true, + }, + "product_id": { + Type: schema.TypeString, + Optional: true, + }, + }, + } +} + +func dataSourceAwsServiceCatalogPortfolioConstraintsRead(d *schema.ResourceData, meta interface{}) error { + conn := meta.(*AWSClient).scconn + + output, err := waiter.PortfolioConstraintsReady(conn, d.Get("accept_language").(string), d.Get("portfolio_id").(string), d.Get("product_id").(string)) + + if err != nil { + return fmt.Errorf("error describing Service Catalog Portfolio Constraints: %w", err) + } + + if len(output) == 0 { + return fmt.Errorf("error getting Service Catalog Portfolio Constraints: no results, change your input") + } + + d.Set("accept_language", d.Get("accept_language").(string)) + d.Set("portfolio_id", d.Get("portfolio_id").(string)) + d.Set("product_id", d.Get("product_id").(string)) + + if err := d.Set("details", flattenServiceCatalogConstraintDetails(output)); err != nil { + return fmt.Errorf("error setting details: %w", err) + } + + d.SetId(tfservicecatalog.PortfolioConstraintsID(d.Get("accept_language").(string), d.Get("portfolio_id").(string), d.Get("product_id").(string))) + + return nil +} + +func flattenServiceCatalogConstraintDetail(apiObject *servicecatalog.ConstraintDetail) map[string]interface{} { + if apiObject == nil { + return nil + } + + tfMap := map[string]interface{}{} + + if v := apiObject.ConstraintId; v != nil { + tfMap["constraint_id"] = aws.StringValue(v) + } + + if v := apiObject.Description; v != nil { + tfMap["description"] = aws.StringValue(v) + } + + if v := apiObject.Owner; v != nil { + tfMap["owner"] = aws.StringValue(v) + } + + if v := apiObject.ProductId; v != nil { + tfMap["product_id"] = aws.StringValue(v) + } + + if v := apiObject.Type; v != nil { + tfMap["type"] = aws.StringValue(v) + } + + return tfMap +} + +func flattenServiceCatalogConstraintDetails(apiObjects []*servicecatalog.ConstraintDetail) []interface{} { + if len(apiObjects) == 0 { + return nil + } + + var tfList []interface{} + + for _, apiObject := range apiObjects { + if apiObject == nil { + continue + } + + tfList = append(tfList, flattenServiceCatalogConstraintDetail(apiObject)) + } + + return tfList +} From 64cbda168fd922830b167c0ceaa40e6943dbe33f Mon Sep 17 00:00:00 2001 From: Dirk Avery Date: Tue, 15 Jun 2021 13:57:15 -0400 Subject: [PATCH 06/12] tests/d/servicecat_port_contraints: New data source --- ...rvicecatalog_portfolio_constraints_test.go | 44 +++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 aws/data_source_aws_servicecatalog_portfolio_constraints_test.go diff --git a/aws/data_source_aws_servicecatalog_portfolio_constraints_test.go b/aws/data_source_aws_servicecatalog_portfolio_constraints_test.go new file mode 100644 index 00000000000..07ae7b5a014 --- /dev/null +++ b/aws/data_source_aws_servicecatalog_portfolio_constraints_test.go @@ -0,0 +1,44 @@ +package aws + +import ( + "testing" + + "github.com/aws/aws-sdk-go/service/servicecatalog" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" +) + +func TestAccAWSServiceCatalogPortfolioConstraintDataSource_basic(t *testing.T) { + resourceName := "aws_servicecatalog_portfolio_constraint.test" + dataSourceName := "data.aws_servicecatalog_portfolio_constraint.test" + rName := acctest.RandomWithPrefix("tf-acc-test") + + resource.ParallelTest(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + ErrorCheck: testAccErrorCheck(t, servicecatalog.EndpointsID), + Providers: testAccProviders, + Steps: []resource.TestStep{ + { + Config: testAccAWSServiceCatalogPortfolioConstraintDataSourceConfig_basic(rName, rName), + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttrPair(resourceName, "accept_language", dataSourceName, "accept_language"), + resource.TestCheckResourceAttrPair(resourceName, "description", dataSourceName, "description"), + resource.TestCheckResourceAttrPair(resourceName, "owner", dataSourceName, "owner"), + resource.TestCheckResourceAttrPair(resourceName, "parameters", dataSourceName, "parameters"), + resource.TestCheckResourceAttrPair(resourceName, "portfolio_id", dataSourceName, "portfolio_id"), + resource.TestCheckResourceAttrPair(resourceName, "product_id", dataSourceName, "product_id"), + resource.TestCheckResourceAttrPair(resourceName, "status", dataSourceName, "status"), + resource.TestCheckResourceAttrPair(resourceName, "type", dataSourceName, "type"), + ), + }, + }, + }) +} + +func testAccAWSServiceCatalogPortfolioConstraintDataSourceConfig_basic(rName, description string) string { + return composeConfig(testAccAWSServiceCatalogPortfolioConstraintConfig_basic(rName, description), ` +data "aws_servicecatalog_portfolio_constraints" "test" { + id = aws_servicecatalog_portfolio_constraint.test.id +} +`) +} From ee8ae7dfcff2c41c23557b64f71a674844e72352 Mon Sep 17 00:00:00 2001 From: Dirk Avery Date: Tue, 15 Jun 2021 14:00:13 -0400 Subject: [PATCH 07/12] d/servicecat_port_contraints: Add changelog --- .changelog/19813.txt | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 .changelog/19813.txt diff --git a/.changelog/19813.txt b/.changelog/19813.txt new file mode 100644 index 00000000000..af1420e8b70 --- /dev/null +++ b/.changelog/19813.txt @@ -0,0 +1,3 @@ +```release-notes:new-data-source +aws_servicecatalog_portfolio_constraints +``` \ No newline at end of file From b05dd884ea5e4ffb9ee9ed81f5042c5d84b52d06 Mon Sep 17 00:00:00 2001 From: Dirk Avery Date: Tue, 29 Jun 2021 19:15:02 -0400 Subject: [PATCH 08/12] r/servicecat_constraint: Add check to avoid panic --- aws/resource_aws_servicecatalog_constraint.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/aws/resource_aws_servicecatalog_constraint.go b/aws/resource_aws_servicecatalog_constraint.go index 730a57020da..8a9f3d46763 100644 --- a/aws/resource_aws_servicecatalog_constraint.go +++ b/aws/resource_aws_servicecatalog_constraint.go @@ -144,7 +144,7 @@ func resourceAwsServiceCatalogConstraintRead(d *schema.ResourceData, meta interf return fmt.Errorf("error describing Service Catalog Constraint (%s): %w", d.Id(), err) } - if output == nil { + if output == nil || output.ConstraintDetail == nil { return fmt.Errorf("error getting Service Catalog Constraint (%s): empty response", d.Id()) } From d73ddf5b1231ab55ecdb76a8655da4fc4899bbdd Mon Sep 17 00:00:00 2001 From: Dirk Avery Date: Tue, 29 Jun 2021 19:16:09 -0400 Subject: [PATCH 09/12] d/servicecat_port_constraints: Minor fixes --- ...aws_servicecatalog_portfolio_constraints.go | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/aws/data_source_aws_servicecatalog_portfolio_constraints.go b/aws/data_source_aws_servicecatalog_portfolio_constraints.go index 4e5e31e7deb..0b89f506851 100644 --- a/aws/data_source_aws_servicecatalog_portfolio_constraints.go +++ b/aws/data_source_aws_servicecatalog_portfolio_constraints.go @@ -19,7 +19,7 @@ func dataSourceAwsServiceCatalogPortfolioConstraints() *schema.Resource { "accept_language": { Type: schema.TypeString, Optional: true, - Default: "en", + Default: tfservicecatalog.AcceptLanguageEnglish, ValidateFunc: validation.StringInSlice(tfservicecatalog.AcceptLanguage_Values(), false), }, "details": { @@ -39,6 +39,10 @@ func dataSourceAwsServiceCatalogPortfolioConstraints() *schema.Resource { Type: schema.TypeString, Computed: true, }, + "portfolio_id": { + Type: schema.TypeString, + Computed: true, + }, "product_id": { Type: schema.TypeString, Computed: true, @@ -75,7 +79,13 @@ func dataSourceAwsServiceCatalogPortfolioConstraintsRead(d *schema.ResourceData, return fmt.Errorf("error getting Service Catalog Portfolio Constraints: no results, change your input") } - d.Set("accept_language", d.Get("accept_language").(string)) + acceptLanguage := d.Get("accept_language").(string) + + if acceptLanguage == "" { + acceptLanguage = tfservicecatalog.AcceptLanguageEnglish + } + + d.Set("accept_language", acceptLanguage) d.Set("portfolio_id", d.Get("portfolio_id").(string)) d.Set("product_id", d.Get("product_id").(string)) @@ -107,6 +117,10 @@ func flattenServiceCatalogConstraintDetail(apiObject *servicecatalog.ConstraintD tfMap["owner"] = aws.StringValue(v) } + if v := apiObject.PortfolioId; v != nil { + tfMap["portfolio_id"] = aws.StringValue(v) + } + if v := apiObject.ProductId; v != nil { tfMap["product_id"] = aws.StringValue(v) } From 50f23a92556438342535015bd9679c5a46979cc6 Mon Sep 17 00:00:00 2001 From: Dirk Avery Date: Tue, 29 Jun 2021 19:18:51 -0400 Subject: [PATCH 10/12] docs/d/servicecat_port_constraints: Add new attribute --- .../docs/d/servicecatalog_portfolio_constraints.html.markdown | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/website/docs/d/servicecatalog_portfolio_constraints.html.markdown b/website/docs/d/servicecatalog_portfolio_constraints.html.markdown index 611a6e148c5..176fdfcf01b 100644 --- a/website/docs/d/servicecatalog_portfolio_constraints.html.markdown +++ b/website/docs/d/servicecatalog_portfolio_constraints.html.markdown @@ -24,7 +24,7 @@ data "aws_servicecatalog_portfolio_constraints" "example" { The following arguments are required: -* `portfolio_id` - Portfolio identifier. +* `portfolio_id` - (Required) Portfolio identifier. The following arguments are optional: @@ -41,5 +41,6 @@ In addition to all arguments above, the following attributes are exported: * `constraint_id` - Identifier of the constraint. * `description` - Description of the constraint. +* `portfolio_id` - Identifier of the portfolio the product resides in. The constraint applies only to the instance of the product that lives within this portfolio. * `product_id` - Identifier of the product the constraint applies to. A constraint applies to a specific instance of a product within a certain portfolio. * `type` - Type of constraint. Valid values are `LAUNCH`, `NOTIFICATION`, `STACKSET`, and `TEMPLATE`. From d8dc758e419ff6d63539b42ac1f83093f3e99b79 Mon Sep 17 00:00:00 2001 From: Dirk Avery Date: Tue, 29 Jun 2021 19:19:46 -0400 Subject: [PATCH 11/12] tests/d/servicecat_port_constraints: Rework test --- ...rvicecatalog_portfolio_constraints_test.go | 25 ++++++++++--------- 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/aws/data_source_aws_servicecatalog_portfolio_constraints_test.go b/aws/data_source_aws_servicecatalog_portfolio_constraints_test.go index 07ae7b5a014..c63eda58851 100644 --- a/aws/data_source_aws_servicecatalog_portfolio_constraints_test.go +++ b/aws/data_source_aws_servicecatalog_portfolio_constraints_test.go @@ -9,8 +9,8 @@ import ( ) func TestAccAWSServiceCatalogPortfolioConstraintDataSource_basic(t *testing.T) { - resourceName := "aws_servicecatalog_portfolio_constraint.test" - dataSourceName := "data.aws_servicecatalog_portfolio_constraint.test" + resourceName := "aws_servicecatalog_constraint.test" + dataSourceName := "data.aws_servicecatalog_portfolio_constraints.test" rName := acctest.RandomWithPrefix("tf-acc-test") resource.ParallelTest(t, resource.TestCase{ @@ -21,14 +21,15 @@ func TestAccAWSServiceCatalogPortfolioConstraintDataSource_basic(t *testing.T) { { Config: testAccAWSServiceCatalogPortfolioConstraintDataSourceConfig_basic(rName, rName), Check: resource.ComposeTestCheckFunc( - resource.TestCheckResourceAttrPair(resourceName, "accept_language", dataSourceName, "accept_language"), - resource.TestCheckResourceAttrPair(resourceName, "description", dataSourceName, "description"), - resource.TestCheckResourceAttrPair(resourceName, "owner", dataSourceName, "owner"), - resource.TestCheckResourceAttrPair(resourceName, "parameters", dataSourceName, "parameters"), - resource.TestCheckResourceAttrPair(resourceName, "portfolio_id", dataSourceName, "portfolio_id"), - resource.TestCheckResourceAttrPair(resourceName, "product_id", dataSourceName, "product_id"), - resource.TestCheckResourceAttrPair(resourceName, "status", dataSourceName, "status"), - resource.TestCheckResourceAttrPair(resourceName, "type", dataSourceName, "type"), + resource.TestCheckResourceAttrPair(dataSourceName, "accept_language", resourceName, "accept_language"), + resource.TestCheckResourceAttr(dataSourceName, "details.#", "1"), + resource.TestCheckResourceAttrPair(dataSourceName, "details.0.constraint_id", resourceName, "id"), + resource.TestCheckResourceAttrPair(dataSourceName, "details.0.description", resourceName, "description"), + resource.TestCheckResourceAttrPair(dataSourceName, "details.0.owner", resourceName, "owner"), + resource.TestCheckResourceAttrPair(dataSourceName, "details.0.portfolio_id", resourceName, "portfolio_id"), + resource.TestCheckResourceAttrPair(dataSourceName, "details.0.product_id", resourceName, "product_id"), + resource.TestCheckResourceAttrPair(dataSourceName, "details.0.type", resourceName, "type"), + resource.TestCheckResourceAttrPair(dataSourceName, "portfolio_id", resourceName, "portfolio_id"), ), }, }, @@ -36,9 +37,9 @@ func TestAccAWSServiceCatalogPortfolioConstraintDataSource_basic(t *testing.T) { } func testAccAWSServiceCatalogPortfolioConstraintDataSourceConfig_basic(rName, description string) string { - return composeConfig(testAccAWSServiceCatalogPortfolioConstraintConfig_basic(rName, description), ` + return composeConfig(testAccAWSServiceCatalogConstraintConfig_basic(rName, description), ` data "aws_servicecatalog_portfolio_constraints" "test" { - id = aws_servicecatalog_portfolio_constraint.test.id + portfolio_id = aws_servicecatalog_constraint.test.portfolio_id } `) } From 058b8ca82ece594fd15eebc519e2a4b3e4ef996d Mon Sep 17 00:00:00 2001 From: Dirk Avery Date: Tue, 29 Jun 2021 19:20:22 -0400 Subject: [PATCH 12/12] d/servicecat_constraint: Align data source with resource --- aws/data_source_aws_servicecatalog_constraint.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/aws/data_source_aws_servicecatalog_constraint.go b/aws/data_source_aws_servicecatalog_constraint.go index a8b29de52c5..4277b4c1771 100644 --- a/aws/data_source_aws_servicecatalog_constraint.go +++ b/aws/data_source_aws_servicecatalog_constraint.go @@ -71,7 +71,13 @@ func dataSourceAwsServiceCatalogConstraintRead(d *schema.ResourceData, meta inte return fmt.Errorf("error getting Service Catalog Constraint: empty response") } - d.Set("accept_language", d.Get("accept_language").(string)) + acceptLanguage := d.Get("accept_language").(string) + + if acceptLanguage == "" { + acceptLanguage = tfservicecatalog.AcceptLanguageEnglish + } + + d.Set("accept_language", acceptLanguage) d.Set("parameters", output.ConstraintParameters) d.Set("status", output.Status)