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/aws_connect_instance - add new resource #16709

Merged
merged 22 commits into from
Sep 23, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
dbb01ed
Feature: AWSConnectInstance Resource
abebars Dec 16, 2020
6ef35c5
Code review
abebars Feb 28, 2021
bc1cd06
Code review
abebars Feb 28, 2021
1d8b346
Fix regex
abebars Feb 28, 2021
0b686fc
Add Error Check
abebars Apr 23, 2021
c5f5209
Format changes `make fmt`
AdamTylerLynch Jul 22, 2021
6e5c378
Refactoring Connect Instance
AdamTylerLynch Jul 31, 2021
313bd21
WIP - refactoring. Need to add Create/Delete wait checks and fix AccT…
AdamTylerLynch Jul 31, 2021
1254465
WIP refactored to match default API values, AccTest_Basic working.
AdamTylerLynch Aug 4, 2021
f2d1256
fix data source acc tests
drewmullen Aug 5, 2021
be0647a
acc test for all attrs
drewmullen Aug 5, 2021
1e93156
Removed use_custom_tts_voices_enabled as it's a pre-release feature a…
AdamTylerLynch Sep 1, 2021
5865150
Combining AccTests to save resources. Fixed Formatting.
AdamTylerLynch Sep 2, 2021
8e107c8
Removed us_voices and finshed stacking AccTests
AdamTylerLynch Sep 3, 2021
b011e48
fixed spacing for linting
AdamTylerLynch Sep 3, 2021
406c9e8
Updated documentation, exposed Timeouts.
AdamTylerLynch Sep 17, 2021
d4f3b00
Fixing linting issues in Connect docs.
AdamTylerLynch Sep 17, 2021
f71a97d
Fixed hcl -> terraform
AdamTylerLynch Sep 17, 2021
4400987
Added Amazon Connect Instance changelog
AdamTylerLynch Sep 20, 2021
c313e27
add plan-time requirement for exactly-on-of argument; use pagination …
anGie44 Sep 23, 2021
08b6773
CR updates; serialize tests since max of 2 can be run in parallel
anGie44 Sep 23, 2021
823d1a7
update data source test to compare attributes with respective resource
anGie44 Sep 23, 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
Combining AccTests to save resources. Fixed Formatting.
  • Loading branch information
AdamTylerLynch authored and anGie44 committed Sep 22, 2021
commit 5865150d602b30ce4a3fa4d45a1f7a98517cfb2e
3 changes: 1 addition & 2 deletions aws/data_source_aws_connect_instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,8 +165,7 @@ func dataSourceAwsConnectGetAllConnectInstanceSummaries(ctx context.Context, con

for {
input := &connect.ListInstancesInput{
// MaxResults Valid Range: Minimum value of 1. Maximum value of 60
MaxResults: aws.Int64(int64(60)),
MaxResults: aws.Int64(int64(tfconnect.ListInstancesMaxResults)),
}
if nextToken != "" {
input.NextToken = aws.String(nextToken)
Expand Down
4 changes: 2 additions & 2 deletions aws/data_source_aws_connect_instance_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ data "aws_connect_instance" "test" {
func testAccAwsConnectInstanceDataSourceConfigBasic(rName string) string {
return fmt.Sprintf(`
resource "aws_connect_instance" "test" {
instance_alias = %[1]q
instance_alias = %[1]q
identity_management_type = "CONNECT_MANAGED"
inbound_calls_enabled = true
outbound_calls_enabled = true
Expand All @@ -108,7 +108,7 @@ data "aws_connect_instance" "test" {
func testAccAwsConnectInstanceDataSourceConfigAlias(rName string) string {
return fmt.Sprintf(`
resource "aws_connect_instance" "test" {
instance_alias = %[1]q
instance_alias = %[1]q
identity_management_type = "CONNECT_MANAGED"
inbound_calls_enabled = true
outbound_calls_enabled = true
Expand Down
4 changes: 4 additions & 0 deletions aws/internal/service/connect/enum.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ import "github.com/aws/aws-sdk-go/service/connect"

const InstanceStatusStatusNotFound = "ResourceNotFoundException"

const (
ListInstancesMaxResults = 10
)

func InstanceAttributeMapping() map[string]string {
return map[string]string{
connect.InstanceAttributeTypeAutoResolveBestVoices: "auto_resolve_best_voices_enabled",
Expand Down
137 changes: 31 additions & 106 deletions aws/resource_aws_connect_instance_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,11 +99,27 @@ func TestAccAwsConnectInstance_basic(t *testing.T) {
ImportState: true,
ImportStateVerify: true,
},
{
Config: testAccAwsConnectInstanceConfigBasicFlipped(rName),
Check: resource.ComposeTestCheckFunc(
testAccCheckAwsConnectInstanceExists(resourceName, &v),
testAccMatchResourceAttrRegionalARN(resourceName, "arn", "connect", regexp.MustCompile(`instance/.+`)),
resource.TestCheckResourceAttr(resourceName, "auto_resolve_best_voices_enabled", "false"),
resource.TestCheckResourceAttr(resourceName, "contact_flow_logs_enabled", "true"),
resource.TestCheckResourceAttr(resourceName, "contact_lens_enabled", "false"),
resource.TestCheckResourceAttrSet(resourceName, "created_time"),
resource.TestCheckResourceAttr(resourceName, "early_media_enabled", "false"),
resource.TestCheckResourceAttr(resourceName, "inbound_calls_enabled", "false"),
resource.TestMatchResourceAttr(resourceName, "instance_alias", regexp.MustCompile(rName)),
resource.TestCheckResourceAttr(resourceName, "outbound_calls_enabled", "false"),
resource.TestCheckResourceAttr(resourceName, "status", connect.InstanceStatusActive),
),
},
},
})
}

func TestAccAwsConnectInstance_custom(t *testing.T) {
func TestAccAwsConnectInstance_directory(t *testing.T) {
var v connect.DescribeInstanceOutput
rName := acctest.RandomWithPrefix("resource-test-terraform")
resourceName := "aws_connect_instance.test"
Expand All @@ -115,51 +131,24 @@ func TestAccAwsConnectInstance_custom(t *testing.T) {
CheckDestroy: testAccCheckAwsConnectInstanceDestroy,
Steps: []resource.TestStep{
{
Config: testAccAwsConnectInstanceConfigCustom(rName),
Config: testAccAwsConnectInstanceConfigDirectory(rName),
Check: resource.ComposeTestCheckFunc(
testAccCheckAwsConnectInstanceExists(resourceName, &v),
testAccMatchResourceAttrRegionalARN(resourceName, "arn", "connect", regexp.MustCompile(`instance/.+`)),
resource.TestCheckResourceAttrSet(resourceName, "created_time"),
resource.TestCheckResourceAttr(resourceName, "identity_management_type", connect.DirectoryTypeConnectManaged),
resource.TestMatchResourceAttr(resourceName, "instance_alias", regexp.MustCompile(rName)),
resource.TestCheckResourceAttr(resourceName, "inbound_calls_enabled", "false"),
resource.TestCheckResourceAttr(resourceName, "outbound_calls_enabled", "false"),
resource.TestCheckResourceAttr(resourceName, "contact_flow_logs_enabled", "true"),
resource.TestCheckResourceAttr(resourceName, "contact_lens_enabled", "false"),
resource.TestCheckResourceAttr(resourceName, "auto_resolve_best_voices_enabled", "false"),
resource.TestCheckResourceAttr(resourceName, "early_media_enabled", "false"),
resource.TestCheckResourceAttr(resourceName, "identity_management_type", connect.DirectoryTypeExistingDirectory),
resource.TestCheckResourceAttr(resourceName, "status", connect.InstanceStatusActive),
testAccMatchResourceAttrGlobalARN(resourceName, "service_role", "iam", regexp.MustCompile(`role/aws-service-role/connect.amazonaws.com/.+`)),
),
},
{
ResourceName: resourceName,
ImportState: true,
ImportStateVerify: true,
},
{
Config: testAccAwsConnectInstanceConfigBasic(rName),
Check: resource.ComposeTestCheckFunc(
testAccCheckAwsConnectInstanceExists(resourceName, &v),
testAccMatchResourceAttrRegionalARN(resourceName, "arn", "connect", regexp.MustCompile(`instance/.+`)),
resource.TestCheckResourceAttr(resourceName, "auto_resolve_best_voices_enabled", "true"), //verified default result from ListInstanceAttributes()
resource.TestCheckResourceAttr(resourceName, "contact_flow_logs_enabled", "false"), //verified default result from ListInstanceAttributes()
resource.TestCheckResourceAttr(resourceName, "contact_lens_enabled", "true"), //verified default result from ListInstanceAttributes()
resource.TestCheckResourceAttrSet(resourceName, "created_time"),
resource.TestCheckResourceAttr(resourceName, "early_media_enabled", "true"), //verified default result from ListInstanceAttributes()
resource.TestCheckResourceAttr(resourceName, "identity_management_type", connect.DirectoryTypeConnectManaged),
resource.TestCheckResourceAttr(resourceName, "inbound_calls_enabled", "true"),
resource.TestMatchResourceAttr(resourceName, "instance_alias", regexp.MustCompile(rName)),
resource.TestCheckResourceAttr(resourceName, "outbound_calls_enabled", "true"),
testAccMatchResourceAttrGlobalARN(resourceName, "service_role", "iam", regexp.MustCompile(`role/aws-service-role/connect.amazonaws.com/.+`)),
resource.TestCheckResourceAttr(resourceName, "status", connect.InstanceStatusActive),
),
ResourceName: resourceName,
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{"directory_id"},
},
},
})
}

func TestAccAwsConnectInstance_directory(t *testing.T) {
func TestAccAwsConnectInstance_saml(t *testing.T) {
var v connect.DescribeInstanceOutput
rName := acctest.RandomWithPrefix("resource-test-terraform")
resourceName := "aws_connect_instance.test"
Expand All @@ -171,17 +160,16 @@ func TestAccAwsConnectInstance_directory(t *testing.T) {
CheckDestroy: testAccCheckAwsConnectInstanceDestroy,
Steps: []resource.TestStep{
{
Config: testAccAwsConnectInstanceConfigDirectory(rName),
Config: testAccAwsConnectInstanceConfigSAML(rName),
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr(resourceName, "identity_management_type", connect.DirectoryTypeExistingDirectory),
resource.TestCheckResourceAttr(resourceName, "identity_management_type", connect.DirectoryTypeSaml),
testAccCheckAwsConnectInstanceExists(resourceName, &v),
),
},
{
ResourceName: resourceName,
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{"directory_id"},
ResourceName: resourceName,
ImportState: true,
ImportStateVerify: true,
},
},
})
Expand Down Expand Up @@ -218,32 +206,6 @@ func testAccCheckAwsConnectInstanceExists(resourceName string, instance *connect
}
}

func TestAccAwsConnectInstance_saml(t *testing.T) {
var v connect.DescribeInstanceOutput
rName := acctest.RandomWithPrefix("resource-test-terraform")
resourceName := "aws_connect_instance.test"

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
ErrorCheck: testAccErrorCheck(t, connect.EndpointsID),
Providers: testAccProviders,
CheckDestroy: testAccCheckAwsConnectInstanceDestroy,
Steps: []resource.TestStep{
{
Config: testAccAwsConnectInstanceConfigSAML(rName),
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr(resourceName, "identity_management_type", connect.DirectoryTypeSaml),
testAccCheckAwsConnectInstanceExists(resourceName, &v),
),
},
{
ResourceName: resourceName,
ImportState: true,
ImportStateVerify: true,
},
},
})
}
func testAccCheckAwsConnectInstanceDestroy(s *terraform.State) error {
for _, rs := range s.RootModule().Resources {
if rs.Type != "aws_connect_instance" {
Expand Down Expand Up @@ -281,7 +243,7 @@ resource "aws_connect_instance" "test" {
`, rName)
}

func testAccAwsConnectInstanceConfigCustom(rName string) string {
func testAccAwsConnectInstanceConfigBasicFlipped(rName string) string {
return fmt.Sprintf(`
resource "aws_connect_instance" "test" {
identity_management_type = "CONNECT_MANAGED"
Expand All @@ -290,42 +252,7 @@ resource "aws_connect_instance" "test" {
outbound_calls_enabled = false
auto_resolve_best_voices_enabled = false
contact_flow_logs_enabled = true
contact_lens_enabled = false
early_media_enabled = false
}
`, rName)
}

func testAccAwsConnectInstanceConfigInboundEnabledOutboundDisabled(rName string) string {
return fmt.Sprintf(`
resource "aws_connect_instance" "test" {
identity_management_type = "CONNECT_MANAGED"
inbound_calls_enabled = true
instance_alias = %[1]q
outbound_calls_enabled = false
}
`, rName)
}

func testAccAwsConnectInstanceConfigInboundDisabledOutboundEnabled(rName string) string {
return fmt.Sprintf(`
resource "aws_connect_instance" "test" {
identity_management_type = "CONNECT_MANAGED"
inbound_calls_enabled = false
instance_alias = %[1]q
outbound_calls_enabled = true
}
`, rName)
}

func testAccAwsConnectInstanceConfigAttributeEarlyMedia(rName string) string {
return fmt.Sprintf(`
resource "aws_connect_instance" "test" {
identity_management_type = "CONNECT_MANAGED"
inbound_calls_enabled = true
instance_alias = %[1]q
outbound_calls_enabled = true
early_media_enabled = true
early_media_enabled = false
}
`, rName)
}
Expand Down Expand Up @@ -383,8 +310,6 @@ resource "aws_connect_instance" "test" {
instance_alias = %[1]q
inbound_calls_enabled = true
outbound_calls_enabled = true

depends_on = [aws_directory_service_directory.test]
}
`, rName)
}
Expand Down
4 changes: 2 additions & 2 deletions website/docs/r/connect_instance.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ Provides an Amazon Connect instance resource. For more information see

## Example Usage

```hcl
resource "aws_connect_instance" "foo" {
```terraform
resource "aws_connect_instance" "test" {
identity_management_type = "CONNECT_MANAGED"
instance_alias = "resource-test-terraform-connect"
inbound_calls_enabled = true
Expand Down