5
5
_ "embed"
6
6
"fmt"
7
7
"os"
8
+ "regexp"
8
9
"testing"
9
10
10
11
"github.com/hashicorp/terraform-plugin-testing/helper/resource"
@@ -88,12 +89,6 @@ func TestAccStreamRSStreamConnection_kafkaNetworkingVPC(t *testing.T) {
88
89
ProtoV6ProviderFactories : acc .TestAccProviderV6Factories ,
89
90
CheckDestroy : CheckDestroyStreamConnection ,
90
91
Steps : []resource.TestStep {
91
- {
92
- Config : networkPeeringConfig + configureKafka (projectID , instanceName , "user" , "rawpassword" , "localhost:9092" , "earliest" , kafkaNetworkingPublic , true ),
93
- Check : resource .ComposeAggregateTestCheckFunc (
94
- checkKafkaAttributes (resourceName , instanceName , "user" , "rawpassword" , "localhost:9092" , "earliest" , networkingTypePublic , true , true ),
95
- ),
96
- },
97
92
{
98
93
Config : networkPeeringConfig + configureKafka (projectID , instanceName , "user" , "rawpassword" , "localhost:9092" , "earliest" , kafkaNetworkingVPC , true ),
99
94
Check : checkKafkaAttributes (resourceName , instanceName , "user" , "rawpassword" , "localhost:9092" , "earliest" , networkingTypeVPC , true , true ),
@@ -111,8 +106,15 @@ func TestAccStreamRSStreamConnection_kafkaNetworkingVPC(t *testing.T) {
111
106
112
107
func TestAccStreamRSStreamConnection_kafkaSSL (t * testing.T ) {
113
108
var (
114
- projectID = acc .ProjectIDExecution (t )
115
- instanceName = acc .RandomName ()
109
+ projectID = acc .ProjectIDExecution (t )
110
+ instanceName = acc .RandomName ()
111
+ vpcID = os .Getenv ("AWS_VPC_ID" )
112
+ vpcCIDRBlock = os .Getenv ("AWS_VPC_CIDR_BLOCK" )
113
+ awsAccountID = os .Getenv ("AWS_ACCOUNT_ID" )
114
+ containerRegion = os .Getenv ("AWS_REGION" )
115
+ peerRegion = conversion .MongoDBRegionToAWSRegion (containerRegion )
116
+ providerName = "AWS"
117
+ networkPeeringConfig = configNetworkPeeringAWS (projectID , providerName , vpcID , awsAccountID , vpcCIDRBlock , containerRegion , peerRegion )
116
118
)
117
119
resource .ParallelTest (t , resource.TestCase {
118
120
PreCheck : func () { acc .PreCheckBasic (t ) },
@@ -123,6 +125,11 @@ func TestAccStreamRSStreamConnection_kafkaSSL(t *testing.T) {
123
125
Config : configureKafka (projectID , instanceName , "user" , "rawpassword" , "localhost:9092" , "earliest" , kafkaNetworkingPublic , true ),
124
126
Check : checkKafkaAttributes (resourceName , instanceName , "user" , "rawpassword" , "localhost:9092" , "earliest" , networkingTypePublic , true , true ),
125
127
},
128
+ // cannot change networking access type once set
129
+ {
130
+ Config : networkPeeringConfig + configureKafka (projectID , instanceName , "user" , "rawpassword" , "localhost:9092" , "earliest" , kafkaNetworkingVPC , true ),
131
+ ExpectError : regexp .MustCompile ("STREAM_NETWORKING_ACCESS_TYPE_CANNOT_BE_MODIFIED" ),
132
+ },
126
133
{
127
134
ResourceName : resourceName ,
128
135
ImportStateIdFunc : checkStreamConnectionImportStateIDFunc (resourceName ),
0 commit comments