-
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_spring_cloud_container_deployment
- support for the application_performance_monitoring_resource_ids
property
#23862
Changes from 3 commits
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 |
---|---|---|
|
@@ -8,6 +8,8 @@ import ( | |
"log" | ||
"time" | ||
|
||
"github.com/hashicorp/go-azure-helpers/lang/pointer" | ||
appplatform2 "github.com/hashicorp/go-azure-sdk/resource-manager/appplatform/2023-09-01-preview/appplatform" | ||
"github.com/hashicorp/terraform-provider-azurerm/helpers/tf" | ||
"github.com/hashicorp/terraform-provider-azurerm/internal/clients" | ||
"github.com/hashicorp/terraform-provider-azurerm/internal/services/springcloud/migration" | ||
|
@@ -79,6 +81,16 @@ func resourceSpringCloudContainerDeployment() *pluginsdk.Resource { | |
DiffSuppressFunc: pluginsdk.SuppressJsonDiff, | ||
}, | ||
|
||
"application_performance_monitoring_resource_ids": { | ||
Type: pluginsdk.TypeList, | ||
Optional: true, | ||
MinItems: 1, | ||
Elem: &pluginsdk.Schema{ | ||
Type: pluginsdk.TypeString, | ||
ValidateFunc: appplatform2.ValidateApmID, | ||
}, | ||
}, | ||
|
||
"arguments": { | ||
Type: pluginsdk.TypeList, | ||
Optional: true, | ||
|
@@ -207,6 +219,7 @@ func resourceSpringCloudContainerDeploymentCreateUpdate(d *pluginsdk.ResourceDat | |
}, | ||
DeploymentSettings: &appplatform.DeploymentSettings{ | ||
AddonConfigs: addonConfig, | ||
Apms: expandSpringCloudDeploymentApms(d.Get("application_performance_monitoring_resource_ids").([]interface{})), | ||
EnvironmentVariables: expandSpringCloudDeploymentEnvironmentVariables(d.Get("environment_variables").(map[string]interface{})), | ||
ResourceRequests: expandSpringCloudContainerDeploymentResourceRequests(d.Get("quota").([]interface{})), | ||
}, | ||
|
@@ -261,6 +274,9 @@ func resourceSpringCloudContainerDeploymentRead(d *pluginsdk.ResourceData, meta | |
if err := d.Set("addon_json", flattenSpringCloudAppAddon(settings.AddonConfigs)); err != nil { | ||
return fmt.Errorf("setting `addon_json`: %s", err) | ||
} | ||
if err := d.Set("application_performance_monitoring_resource_ids", flattenSpringCloudDeploymentApms(settings.Apms)); err != nil { | ||
return fmt.Errorf("setting `application_performance_monitoring_resource_ids`: %+v", err) | ||
} | ||
} | ||
if source, ok := resp.Properties.Source.AsCustomContainerUserSourceInfo(); ok && source != nil { | ||
if container := source.CustomContainer; container != nil { | ||
|
@@ -320,3 +336,32 @@ func expandSpringCloudContainerDeploymentResourceRequests(input []interface{}) * | |
|
||
return &result | ||
} | ||
|
||
func expandSpringCloudDeploymentApms(input []interface{}) *[]appplatform.ApmReference { | ||
if len(input) == 0 { | ||
return nil | ||
} | ||
result := make([]appplatform.ApmReference, 0) | ||
for _, v := range input { | ||
result = append(result, appplatform.ApmReference{ | ||
ResourceID: pointer.To(v.(string)), | ||
}) | ||
} | ||
return pointer.To(result) | ||
} | ||
|
||
func flattenSpringCloudDeploymentApms(input *[]appplatform.ApmReference) []interface{} { | ||
if input == nil { | ||
return nil | ||
} | ||
result := make([]interface{}, 0) | ||
for _, v := range *input { | ||
id, err := appplatform2.ParseApmIDInsensitively(*v.ResourceID) | ||
if err != nil { | ||
log.Printf("[WARN] invalid APM ID %q: %+v", *v.ResourceID, err) | ||
continue | ||
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. We should be throwing an error here if the resource ID can't be parsed since this would indicate a problem in the API that the service team should fix. If we silently log a warning and continue we would be allowing malformed resource ID's to creep into the state which will cause problems further down the line if user's try to use these for something else. 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. Got it! I've updated this PR, please take another look, thanks! |
||
} | ||
result = append(result, id.ID()) | ||
} | ||
return result | ||
} |
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.
When we're referencing the ids of other resources in the azurerm provider we don't specify resource. This should be renamed to
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.
Got it!