Skip to content

Commit

Permalink
wait for SA to propagate on beyondcord app (#12365)
Browse files Browse the repository at this point in the history
  • Loading branch information
ScottSuarez authored Nov 20, 2024
1 parent 37310e5 commit 318f4fe
Show file tree
Hide file tree
Showing 5 changed files with 98 additions and 40 deletions.
2 changes: 2 additions & 0 deletions mmv1/products/beyondcorp/AppConnection.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ examples:
account_id: 'my-account'
app_connector_name: 'my-app-connector'
app_connection_name: 'my-app-connection'
external_providers: ["time"]
- name: 'beyondcorp_app_connection_full'
primary_resource_id: 'app_connection'
primary_resource_name: 'fmt.Sprintf("tf_test_my_app_connection%s", context["random_suffix"])'
Expand All @@ -68,6 +69,7 @@ examples:
app_connector_name: 'my-app-connector'
app_connection_name: 'my-app-connection'
display_name: 'some display name'
external_providers: ["time"]
parameters:
properties:
- name: 'name'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,18 @@ resource "google_service_account" "service_account" {
display_name = "Test Service Account"
}

# wait for service account to propagate -- can be needed due to
# SA eventual consistency issue
resource "time_sleep" "wait_120_seconds" {
depends_on = [google_service_account.service_account]

create_duration = "120s"
}


resource "google_beyondcorp_app_connector" "app_connector" {
depends_on = [time_sleep.wait_120_seconds]

name = "{{index $.Vars "app_connector_name"}}"
principal_info {
service_account {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,23 @@ resource "google_service_account" "service_account" {
display_name = "Test Service Account"
}

# wait for service account to propagate -- can be needed due to
# SA eventual consistency issue
resource "time_sleep" "wait_120_seconds" {
depends_on = [google_service_account.service_account]

create_duration = "120s"
}

resource "google_beyondcorp_app_gateway" "app_gateway" {
name = "{{index $.Vars "app_gateway_name"}}"
type = "TCP_PROXY"
host_type = "GCP_REGIONAL_MIG"
}

resource "google_beyondcorp_app_connector" "app_connector" {
depends_on = [time_sleep.wait_120_seconds]

name = "{{index $.Vars "app_connector_name"}}"
principal_info {
service_account {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@ func TestAccDataSourceGoogleBeyondcorpAppConnection_basic(t *testing.T) {
acctest.VcrTest(t, resource.TestCase{
PreCheck: func() { acctest.AccTestPreCheck(t) },
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t),
CheckDestroy: testAccCheckBeyondcorpAppConnectionDestroyProducer(t),
ExternalProviders: map[string]resource.ExternalProvider{
"time": {},
},
CheckDestroy: testAccCheckBeyondcorpAppConnectionDestroyProducer(t),
Steps: []resource.TestStep{
{
Config: testAccDataSourceGoogleBeyondcorpAppConnection_basic(context),
Expand All @@ -40,7 +43,10 @@ func TestAccDataSourceGoogleBeyondcorpAppConnection_full(t *testing.T) {
acctest.VcrTest(t, resource.TestCase{
PreCheck: func() { acctest.AccTestPreCheck(t) },
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t),
CheckDestroy: testAccCheckBeyondcorpAppConnectionDestroyProducer(t),
ExternalProviders: map[string]resource.ExternalProvider{
"time": {},
},
CheckDestroy: testAccCheckBeyondcorpAppConnectionDestroyProducer(t),
Steps: []resource.TestStep{
{
Config: testAccDataSourceGoogleBeyondcorpAppConnection_full(context),
Expand All @@ -55,68 +61,85 @@ func TestAccDataSourceGoogleBeyondcorpAppConnection_full(t *testing.T) {
func testAccDataSourceGoogleBeyondcorpAppConnection_basic(context map[string]interface{}) string {
return acctest.Nprintf(`
resource "google_service_account" "service_account" {
account_id = "tf-test-my-account%{random_suffix}"
display_name = "Test Service Account"
account_id = "tf-test-my-account%{random_suffix}"
display_name = "Test Service Account"
}
resource "time_sleep" "wait_120_seconds" {
depends_on = [google_service_account.service_account]
create_duration = "120s"
}
resource "google_beyondcorp_app_connector" "app_connector" {
name = "tf-test-appconnector-%{random_suffix}"
principal_info {
service_account {
email = google_service_account.service_account.email
}
}
depends_on = [time_sleep.wait_120_seconds]
name = "tf-test-appconnector-%{random_suffix}"
principal_info {
service_account {
email = google_service_account.service_account.email
}
}
}
resource "google_beyondcorp_app_connection" "foo" {
name = "tf-test-my-app-connection-%{random_suffix}"
type = "TCP_PROXY"
application_endpoint {
host = "foo-host"
port = 8080
}
connectors = [google_beyondcorp_app_connector.app_connector.id]
labels = {
my-label = "my-label-value"
}
name = "tf-test-my-app-connection-%{random_suffix}"
type = "TCP_PROXY"
application_endpoint {
host = "foo-host"
port = 8080
}
connectors = [google_beyondcorp_app_connector.app_connector.id]
labels = {
my-label = "my-label-value"
}
}
data "google_beyondcorp_app_connection" "foo" {
name = google_beyondcorp_app_connection.foo.name
name = google_beyondcorp_app_connection.foo.name
}
`, context)
}

func testAccDataSourceGoogleBeyondcorpAppConnection_full(context map[string]interface{}) string {
return acctest.Nprintf(`
resource "google_service_account" "service_account" {
account_id = "tf-test-my-account%{random_suffix}"
display_name = "Test Service Account"
account_id = "tf-test-my-account%{random_suffix}"
display_name = "Test Service Account"
}
resource "time_sleep" "wait_120_seconds" {
depends_on = [google_service_account.service_account]
create_duration = "120s"
}
resource "google_beyondcorp_app_connector" "app_connector" {
name = "tf-test-appconnector-%{random_suffix}"
principal_info {
service_account {
email = google_service_account.service_account.email
}
}
depends_on = [time_sleep.wait_120_seconds]
name = "tf-test-appconnector-%{random_suffix}"
principal_info {
service_account {
email = google_service_account.service_account.email
}
}
}
resource "google_beyondcorp_app_connection" "foo" {
name = "tf-test-my-app-connection-%{random_suffix}"
type = "TCP_PROXY"
application_endpoint {
host = "foo-host"
port = 8080
}
connectors = [google_beyondcorp_app_connector.app_connector.id]
name = "tf-test-my-app-connection-%{random_suffix}"
type = "TCP_PROXY"
application_endpoint {
host = "foo-host"
port = 8080
}
connectors = [google_beyondcorp_app_connector.app_connector.id]
}
data "google_beyondcorp_app_connection" "foo" {
name = google_beyondcorp_app_connection.foo.name
project = google_beyondcorp_app_connection.foo.project
region = google_beyondcorp_app_connection.foo.region
name = google_beyondcorp_app_connection.foo.name
project = google_beyondcorp_app_connection.foo.project
region = google_beyondcorp_app_connection.foo.region
}
`, context)
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@ func TestAccBeyondcorpAppConnection_beyondcorpAppConnectionUpdateExample(t *test
acctest.VcrTest(t, resource.TestCase{
PreCheck: func() { acctest.AccTestPreCheck(t) },
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t),
CheckDestroy: testAccCheckBeyondcorpAppConnectionDestroyProducer(t),
ExternalProviders: map[string]resource.ExternalProvider{
"time": {},
},
CheckDestroy: testAccCheckBeyondcorpAppConnectionDestroyProducer(t),
Steps: []resource.TestStep{
{
Config: testAccBeyondcorpAppConnection_beyondcorpAppConnectionBasicExample(context),
Expand Down Expand Up @@ -51,7 +54,16 @@ resource "google_service_account" "service_account" {
display_name = "Test Service Account"
}
resource "time_sleep" "wait_120_seconds" {
depends_on = [google_service_account.service_account]
create_duration = "120s"
}
resource "google_beyondcorp_app_connector" "app_connector" {
depends_on = [time_sleep.wait_120_seconds]
name = "tf-test-my-app-connector%{random_suffix}"
principal_info {
service_account {
Expand Down

0 comments on commit 318f4fe

Please sign in to comment.