-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
azurerm_container_app_environment
: fix infrastructure_resource_group_name
behavior with workload_profile
set to Consumption
#27502
base: main
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -103,13 +103,9 @@ func (r ContainerAppEnvironmentResource) Arguments() map[string]*pluginsdk.Schem | |
RequiredWith: []string{"workload_profile"}, | ||
ValidateFunc: resourcegroups.ValidateName, | ||
DiffSuppressOnRefresh: true, | ||
DiffSuppressFunc: func(k, oldValue, newValue string, d *pluginsdk.ResourceData) bool { // If this is omitted, and there is a non-consumption profile, then the service generates a value for the required manage resource group. | ||
DiffSuppressFunc: func(k, oldValue, newValue string, d *pluginsdk.ResourceData) bool { // If this is omitted, then the service generates a value for the required manage resource group. | ||
if profiles := d.Get("workload_profile").(*pluginsdk.Set).List(); len(profiles) > 0 && newValue == "" { | ||
for _, profile := range profiles { | ||
if profile.(map[string]interface{})["workload_profile_type"].(string) != string(helpers.WorkloadProfileSkuConsumption) { | ||
return true | ||
} | ||
} | ||
return true | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. LGTM 👍🏻 |
||
} | ||
return false | ||
}, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -175,6 +175,21 @@ func TestAccContainerAppEnvironment_infraResourceGroupWithoutName(t *testing.T) | |
}) | ||
} | ||
|
||
func TestAccContainerAppEnvironment_infraResourceGroupWithConsumptionWorkloadProfile(t *testing.T) { | ||
data := acceptance.BuildTestData(t, "azurerm_container_app_environment", "test") | ||
r := ContainerAppEnvironmentResource{} | ||
|
||
data.ResourceTest(t, r, []acceptance.TestStep{ | ||
{ | ||
Config: r.infraResourceGroupWithConsumptionWorkloadProfile(data), | ||
Check: acceptance.ComposeTestCheckFunc( | ||
check.That(data.ResourceName).ExistsInAzure(r), | ||
), | ||
}, | ||
data.ImportStep("workload_profile"), | ||
}) | ||
} | ||
|
||
func (r ContainerAppEnvironmentResource) Exists(ctx context.Context, client *clients.Client, state *pluginsdk.InstanceState) (*bool, error) { | ||
id, err := managedenvironments.ParseManagedEnvironmentID(state.ID) | ||
if err != nil { | ||
|
@@ -581,3 +596,32 @@ resource "azurerm_container_app_environment" "test" { | |
} | ||
`, r.templateVNet(data), data.RandomInteger) | ||
} | ||
|
||
func (r ContainerAppEnvironmentResource) infraResourceGroupWithConsumptionWorkloadProfile(data acceptance.TestData) string { | ||
return fmt.Sprintf(` | ||
provider "azurerm" { | ||
features {} | ||
} | ||
|
||
%[1]s | ||
|
||
resource "azurerm_container_app_environment" "test" { | ||
name = "acctest-CAEnv%[2]d" | ||
resource_group_name = azurerm_resource_group.test.name | ||
location = azurerm_resource_group.test.location | ||
infrastructure_subnet_id = azurerm_subnet.control.id | ||
|
||
workload_profile { | ||
name = "Consumption" | ||
workload_profile_type = "Consumption" | ||
} | ||
|
||
zone_redundancy_enabled = true | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. When here the intention is to test the configuration with infrastructure_subnet_id and workload_profile only I think There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sure. |
||
|
||
tags = { | ||
Foo = "Bar" | ||
secret = "sauce" | ||
} | ||
} | ||
`, r.templateVNet(data), data.RandomInteger) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make sense, will add this line.