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

feat: fixes region and aws account to be used for trigger acc test #1558

Merged
merged 8 commits into from
Oct 30, 2023
49 changes: 25 additions & 24 deletions mongodbatlas/resource_mongodbatlas_event_trigger_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"github.com/hashicorp/terraform-plugin-testing/helper/acctest"
"github.com/hashicorp/terraform-plugin-testing/helper/resource"
"github.com/hashicorp/terraform-plugin-testing/terraform"
"github.com/mongodb/terraform-provider-mongodbatlas/mongodbatlas/util"
"github.com/mwielbut/pointy"
"go.mongodb.org/realm/realm"
)
Expand Down Expand Up @@ -80,12 +81,12 @@ func TestAccConfigRSEventTriggerDatabase_basic(t *testing.T) {
func TestAccConfigRSEventTriggerDatabase_eventProccesor(t *testing.T) {
SkipTestForCI(t)
var (
resourceName = "mongodbatlas_event_trigger.test"
projectID = os.Getenv("MONGODB_ATLAS_PROJECT_ID")
awsAccountID = os.Getenv("AWS_ACCOUNT_ID")
awsRegion = os.Getenv("AWS_REGION")
appID = os.Getenv("MONGODB_REALM_APP_ID")
eventResp = realm.EventTrigger{}
resourceName = "mongodbatlas_event_trigger.test"
projectID = os.Getenv("MONGODB_ATLAS_PROJECT_ID")
eventBridgeAwsAccountID = os.Getenv("AWS_EVENTBRIDGE_ACCOUNT_ID")
eventBridgeAwsRegion = util.MongoDBRegionToAWSRegion(os.Getenv("AWS_REGION"))
appID = os.Getenv("MONGODB_REALM_APP_ID")
eventResp = realm.EventTrigger{}
)
event := realm.EventTriggerRequest{
Name: acctest.RandomWithPrefix("test-acc"),
Expand Down Expand Up @@ -120,14 +121,14 @@ func TestAccConfigRSEventTriggerDatabase_eventProccesor(t *testing.T) {
CheckDestroy: testAccCheckMongoDBAtlasEventTriggerDestroy,
Steps: []resource.TestStep{
{
Config: testAccMongoDBAtlasEventTriggerDatabaseConfigDatabaseEP(projectID, appID, `"INSERT", "UPDATE"`, awsAccountID, awsRegion, &event),
Config: testAccMongoDBAtlasEventTriggerDatabaseConfigDatabaseEP(projectID, appID, `"INSERT", "UPDATE"`, eventBridgeAwsAccountID, eventBridgeAwsRegion, &event),
Check: resource.ComposeTestCheckFunc(
testAccCheckMongoDBAtlasEventTriggerExists(resourceName, &eventResp),
resource.TestCheckResourceAttr(resourceName, "project_id", projectID),
),
},
{
Config: testAccMongoDBAtlasEventTriggerDatabaseConfigDatabaseEP(projectID, appID, `"INSERT", "UPDATE", "DELETE"`, awsAccountID, awsRegion, &eventUpdated),
Config: testAccMongoDBAtlasEventTriggerDatabaseConfigDatabaseEP(projectID, appID, `"INSERT", "UPDATE", "DELETE"`, eventBridgeAwsAccountID, eventBridgeAwsRegion, &eventUpdated),
Check: resource.ComposeTestCheckFunc(
testAccCheckMongoDBAtlasEventTriggerExists(resourceName, &eventResp),
resource.TestCheckResourceAttr(resourceName, "project_id", projectID),
Expand Down Expand Up @@ -205,12 +206,12 @@ func TestAccConfigRSEventTriggerAuth_basic(t *testing.T) {
func TestAccConfigRSEventTriggerAuth_eventProcessor(t *testing.T) {
SkipTestForCI(t)
var (
resourceName = "mongodbatlas_event_trigger.test"
projectID = os.Getenv("MONGODB_ATLAS_PROJECT_ID")
awsAccountID = os.Getenv("AWS_ACCOUNT_ID")
awsRegion = os.Getenv("AWS_REGION")
appID = os.Getenv("MONGODB_REALM_APP_ID")
eventResp = realm.EventTrigger{}
resourceName = "mongodbatlas_event_trigger.test"
projectID = os.Getenv("MONGODB_ATLAS_PROJECT_ID")
eventBridgeAwsAccountID = os.Getenv("AWS_EVENTBRIDGE_ACCOUNT_ID")
eventBridgeAwsRegion = util.MongoDBRegionToAWSRegion(os.Getenv("AWS_REGION"))
appID = os.Getenv("MONGODB_REALM_APP_ID")
eventResp = realm.EventTrigger{}
)
event := realm.EventTriggerRequest{
Name: acctest.RandomWithPrefix("test-acc"),
Expand Down Expand Up @@ -240,14 +241,14 @@ func TestAccConfigRSEventTriggerAuth_eventProcessor(t *testing.T) {
CheckDestroy: testAccCheckMongoDBAtlasEventTriggerDestroy,
Steps: []resource.TestStep{
{
Config: testAccMongoDBAtlasEventTriggerDatabaseConfigAuthenticationEP(projectID, appID, `"anon-user", "local-userpass"`, awsAccountID, awsRegion, &event),
Config: testAccMongoDBAtlasEventTriggerDatabaseConfigAuthenticationEP(projectID, appID, `"anon-user", "local-userpass"`, eventBridgeAwsAccountID, eventBridgeAwsRegion, &event),
Check: resource.ComposeTestCheckFunc(
testAccCheckMongoDBAtlasEventTriggerExists(resourceName, &eventResp),
resource.TestCheckResourceAttr(resourceName, "project_id", projectID),
),
},
{
Config: testAccMongoDBAtlasEventTriggerDatabaseConfigAuthenticationEP(projectID, appID, `"anon-user", "local-userpass", "api-key"`, awsAccountID, awsRegion, &eventUpdated),
Config: testAccMongoDBAtlasEventTriggerDatabaseConfigAuthenticationEP(projectID, appID, `"anon-user", "local-userpass", "api-key"`, eventBridgeAwsAccountID, eventBridgeAwsRegion, &eventUpdated),
Check: resource.ComposeTestCheckFunc(
testAccCheckMongoDBAtlasEventTriggerExists(resourceName, &eventResp),
resource.TestCheckResourceAttr(resourceName, "project_id", projectID),
Expand Down Expand Up @@ -322,12 +323,12 @@ func TestAccConfigRSEventTriggerSchedule_basic(t *testing.T) {
func TestAccConfigRSEventTriggerSchedule_eventProcessor(t *testing.T) {
SkipTestForCI(t)
var (
resourceName = "mongodbatlas_event_trigger.test"
projectID = os.Getenv("MONGODB_ATLAS_PROJECT_ID")
awsAccountID = os.Getenv("AWS_ACCOUNT_ID")
awsRegion = os.Getenv("AWS_REGION")
appID = os.Getenv("MONGODB_REALM_APP_ID")
eventResp = realm.EventTrigger{}
resourceName = "mongodbatlas_event_trigger.test"
projectID = os.Getenv("MONGODB_ATLAS_PROJECT_ID")
eventBridgeAwsAccountID = os.Getenv("AWS_EVENTBRIDGE_ACCOUNT_ID")
eventBridgeAwsRegion = util.MongoDBRegionToAWSRegion(os.Getenv("AWS_REGION"))
appID = os.Getenv("MONGODB_REALM_APP_ID")
eventResp = realm.EventTrigger{}
)
event := realm.EventTriggerRequest{
Name: acctest.RandomWithPrefix("test-acc"),
Expand All @@ -354,14 +355,14 @@ func TestAccConfigRSEventTriggerSchedule_eventProcessor(t *testing.T) {
CheckDestroy: testAccCheckMongoDBAtlasEventTriggerDestroy,
Steps: []resource.TestStep{
{
Config: testAccMongoDBAtlasEventTriggerDatabaseConfigScheduleEP(projectID, appID, awsAccountID, awsRegion, &event),
Config: testAccMongoDBAtlasEventTriggerDatabaseConfigScheduleEP(projectID, appID, eventBridgeAwsAccountID, eventBridgeAwsRegion, &event),
Check: resource.ComposeTestCheckFunc(
testAccCheckMongoDBAtlasEventTriggerExists(resourceName, &eventResp),
resource.TestCheckResourceAttr(resourceName, "project_id", projectID),
),
},
{
Config: testAccMongoDBAtlasEventTriggerDatabaseConfigScheduleEP(projectID, appID, awsAccountID, awsRegion, &eventUpdated),
Config: testAccMongoDBAtlasEventTriggerDatabaseConfigScheduleEP(projectID, appID, eventBridgeAwsAccountID, eventBridgeAwsRegion, &eventUpdated),
Check: resource.ComposeTestCheckFunc(
testAccCheckMongoDBAtlasEventTriggerExists(resourceName, &eventResp),
resource.TestCheckResourceAttr(resourceName, "project_id", projectID),
Expand Down