Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

r/servicecatalog_portfolio_share: New resource(s) #19278

Merged
merged 41 commits into from
May 14, 2021
Merged
Changes from 1 commit
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
253c128
r/servicecatalog_portfolio: Remove unnecessary length limits
YakDriver May 7, 2021
255f8c7
provider: Add new servicecatalog resources
YakDriver May 7, 2021
c17914e
servicecatalog: Add status for orgs/portfolio_share
YakDriver May 7, 2021
4a62855
servicecatalog: Add waiter for orgs/portfolio_share
YakDriver May 7, 2021
7455a84
servicecatalog: Add finder for portfolio share
YakDriver May 7, 2021
1758402
docs/r/servicecatalog_portfolio_share: Initial docs
YakDriver May 7, 2021
5765062
r/servicecatalog_portfolio_share: New resource
YakDriver May 7, 2021
9cee563
tests/r/servicecatalog_portfolio_share: Tests for new resource
YakDriver May 7, 2021
faa71ad
docs/r/servicecatalog_organizations_access: Docs
YakDriver May 7, 2021
fdbfe4a
tests/r/servicecatalog_organizations_acess: Test new resource
YakDriver May 7, 2021
63e8535
r/servicecatalog_organizations_acess: New resource
YakDriver May 7, 2021
cdf8b43
r/servicecatalog_portfolio_share: Add changelog
YakDriver May 7, 2021
0a3598e
tests/validators: Add test for servicecatalog principal
YakDriver May 7, 2021
7fbba43
validators: Add validator for servicecatalog principal
YakDriver May 7, 2021
26e8e38
r/servicecatalog_portfolio_share: Rework schema to simplify
YakDriver May 7, 2021
cdd59c7
tests/r/servicecatalog_portfolio_share: Rework tests for new schema
YakDriver May 7, 2021
9aa9c29
internal/servicecatalog: Rework finder for new schema
YakDriver May 7, 2021
478202d
internal/servicecatalog: Rework status for new schema
YakDriver May 7, 2021
96d4bd4
internal/servicecatalog: Rework waiter for new schema
YakDriver May 7, 2021
14d340f
docs/r/servicecatalog_portfolio_share: Update for schema rework
YakDriver May 7, 2021
92253f3
docs/r/servicecatalog_portfolio_share: Add wait arg
YakDriver May 7, 2021
5d259d7
internal/servicecatalog: Adjust not found errors
YakDriver May 7, 2021
a4ea865
internal/servicecatalog: Adjust not found errors
YakDriver May 7, 2021
ea82747
tests/r/servicecatalog_portfolio_share: Add new account test
YakDriver May 7, 2021
75e28a7
r/servicecatalog_portfolio_share: Adjust for wait option
YakDriver May 7, 2021
547f518
envvar: Add skipping option func
YakDriver May 7, 2021
34ccacb
provider: Skip when prequisite alt acct envvars not set
YakDriver May 7, 2021
c1a29fd
tests/r/servicecatalog_portfolio_share: Add prechecks
YakDriver May 7, 2021
a1bfca5
tests/r/servicecatalog_portfolio_share: Hardcoded fix
YakDriver May 7, 2021
44861f3
envvar: Update skip func docs
YakDriver May 7, 2021
56e278b
provider: Add servicecatalog resource
YakDriver May 7, 2021
cd74e57
tests/r/servicecatalog_portfolio_share: Remove hardcoded partition
YakDriver May 7, 2021
a6166f5
r/servicecatalog_portfolio_share: Move id stuff to internal
YakDriver May 11, 2021
26c06ed
r/servicecat_org_access: Clean up messages, delete
YakDriver May 11, 2021
6d12cff
r/servicecat_portfolio: Enforce field lengths
YakDriver May 11, 2021
ea01f5c
r/servicecat_portfolio_share: Use internal ID helper
YakDriver May 11, 2021
1eb17f2
Add 'testAccOrganizationManagementAccountPreCheck'.
ewbankkit May 13, 2021
40d9bbe
Fix type casting error.
ewbankkit May 13, 2021
0b71dd4
r/servicecat_portfolio_share: Revise org test
YakDriver May 14, 2021
cb8d633
r/servicecat_portfolio_share: Finder contains string
YakDriver May 14, 2021
5635137
r/aws_servicecatalog_portfolio_share: Get tests working for organizat…
ewbankkit May 14, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
tests/r/servicecatalog_organizations_acess: Test new resource
  • Loading branch information
YakDriver committed May 14, 2021
commit fdbfe4a1b14a51f625e5dc8bc37021f89115f62e
95 changes: 95 additions & 0 deletions aws/resource_aws_servicecatalog_organizations_access_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
package aws

import (
"fmt"
"testing"

"github.com/aws/aws-sdk-go/service/servicecatalog"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/v2/terraform"
"github.com/terraform-providers/terraform-provider-aws/aws/internal/service/servicecatalog/waiter"
)

func TestAccAWSServiceCatalogOrganizationsAccess_basic(t *testing.T) {
resourceName := "aws_servicecatalog_organizations_access.test"

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t); testAccOrganizationsAccountPreCheck(t) },
ErrorCheck: testAccErrorCheck(t, servicecatalog.EndpointsID),
Providers: testAccProviders,
CheckDestroy: testAccCheckAwsServiceCatalogOrganizationsAccessDestroy,
Steps: []resource.TestStep{
{
Config: testAccAWSServiceCatalogOrganizationsAccessConfig_basic(),
Check: resource.ComposeTestCheckFunc(
testAccCheckAwsServiceCatalogOrganizationsAccessExists(resourceName),
resource.TestCheckResourceAttr(resourceName, "enabled", "true"),
),
},
},
})
}

func testAccCheckAwsServiceCatalogOrganizationsAccessDestroy(s *terraform.State) error {
conn := testAccProvider.Meta().(*AWSClient).scconn

for _, rs := range s.RootModule().Resources {
if rs.Type != "aws_servicecatalog_organizations_access" {
continue
}

output, err := waiter.OrganizationsAccessStable(conn)

if err != nil {
return fmt.Errorf("error describing Service Catalog AWS Organizations Access (%s): %w", rs.Primary.ID, err)
}

if output == "" {
return fmt.Errorf("error getting Service Catalog AWS Organizations Access (%s): empty response", rs.Primary.ID)
}

return nil
}

return nil
}

func testAccCheckAwsServiceCatalogOrganizationsAccessExists(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 := testAccProvider.Meta().(*AWSClient).scconn

output, err := waiter.OrganizationsAccessStable(conn)

if err != nil {
return fmt.Errorf("error describing Service Catalog AWS Organizations Access (%s): %w", rs.Primary.ID, err)
}

if output == "" {
return fmt.Errorf("error getting Service Catalog AWS Organizations Access (%s): empty response", rs.Primary.ID)
}

if output != servicecatalog.AccessStatusEnabled && rs.Primary.Attributes["enabled"] == "true" {
return fmt.Errorf("error getting Service Catalog AWS Organizations Access (%s): wrong setting", rs.Primary.ID)
}

if output == servicecatalog.AccessStatusEnabled && rs.Primary.Attributes["enabled"] == "false" {
return fmt.Errorf("error getting Service Catalog AWS Organizations Access (%s): wrong setting", rs.Primary.ID)
}

return nil
}
}

func testAccAWSServiceCatalogOrganizationsAccessConfig_basic() string {
return `
resource "aws_servicecatalog_organizations_access" "test" {
enabled = "true"
}
`
}