Skip to content

Commit 9f999bf

Browse files
feat: add cam azure connector support auto-discovery (#62)
1 parent 4b77ee6 commit 9f999bf

3 files changed

Lines changed: 17 additions & 0 deletions

File tree

docs/resources/cam_connector_azure.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ resource "visionone_cam_connector_azure" "cam_connector_with_mgmt_group" {
3737
is_shared_application = true
3838
cam_deployed_region = "us-east-1"
3939
40+
auto_discovery_enabled = false
41+
4042
management_group_details = {
4143
id = "mg-production"
4244
display_name = "Production Management Group"
@@ -216,6 +218,7 @@ resource "visionone_cam_connector_azure" "cam_connector_with_features_config" {
216218

217219
### Optional
218220

221+
- `auto_discovery_enabled` (Boolean) Whether the auto-subscription-discovery Terraform template variant has been applied for this management group. Set by the CAM template generator; defaults to `false`. Only read on the primary subscription.
219222
- `cam_deployed_region` (String) Region where CAM is deployed for this connector
220223
- `connected_security_services` (Attributes List) List of connected security services for the connector (see [below for nested schema](#nestedatt--connected_security_services))
221224
- `description` (String) Description of the connector

internal/trendmicro/cloud_account_management/azure/api/cam_connector.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ type CreateSubscriptionRequest struct {
2626
IsTFProviderDeployed bool `json:"isTFProviderDeployed"`
2727
Features *[]Feature `json:"features,omitempty"`
2828
FeaturesConfigFilePath string `json:"featuresConfigFilePath,omitempty"`
29+
AutoDiscoveryEnabled bool `json:"autoDiscoveryEnabled"`
2930
}
3031

3132
type ModifySubscriptionRequest struct {
@@ -42,6 +43,7 @@ type ModifySubscriptionRequest struct {
4243
IsTFProviderDeployed bool `json:"isTFProviderDeployed"`
4344
Features *[]Feature `json:"features,omitempty"`
4445
FeaturesConfigFilePath string `json:"featuresConfigFilePath,omitempty"`
46+
AutoDiscoveryEnabled bool `json:"autoDiscoveryEnabled"`
4547
}
4648

4749
type SubscriptionResponse struct {

internal/trendmicro/cloud_account_management/azure/resources/cam_connector.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ type CAMConnectorResourceModel struct {
6767
Features types.List `tfsdk:"features"`
6868
FeaturesConfigFilePath types.String `tfsdk:"features_config_file_path"`
6969
PreventDestroy types.Bool `tfsdk:"prevent_destroy"`
70+
AutoDiscoveryEnabled types.Bool `tfsdk:"auto_discovery_enabled"`
7071
}
7172

7273
type ManagementGroupDetailsModel struct {
@@ -232,6 +233,12 @@ func (r *CAMConnectorResource) Schema(ctx context.Context, req resource.SchemaRe
232233
MarkdownDescription: "When `true` (default), Terraform destroy will not call the CAM DELETE API, preserving the subscription in CAM. Set to `false` to allow the subscription to be removed from CAM on destroy.",
233234
Default: booldefault.StaticBool(true),
234235
},
236+
"auto_discovery_enabled": schema.BoolAttribute{
237+
Optional: true,
238+
Computed: true,
239+
MarkdownDescription: "Whether the auto-subscription-discovery Terraform template variant has been applied for this management group. Set by the CAM template generator; defaults to `false`. Only read on the primary subscription.",
240+
Default: booldefault.StaticBool(false),
241+
},
235242
},
236243
}
237244
}
@@ -354,6 +361,7 @@ func (r *CAMConnectorResource) Create(ctx context.Context, req resource.CreateRe
354361
IsTFProviderDeployed: true,
355362
Features: features,
356363
FeaturesConfigFilePath: plan.FeaturesConfigFilePath.ValueString(),
364+
AutoDiscoveryEnabled: plan.AutoDiscoveryEnabled.ValueBool(),
357365
}
358366

359367
createErr := r.client.CreateSubscription(body)
@@ -485,6 +493,7 @@ func (r *CAMConnectorResource) Read(ctx context.Context, req resource.ReadReques
485493
IsTFProviderDeployed: true,
486494
Features: stateFeatures,
487495
FeaturesConfigFilePath: state.FeaturesConfigFilePath.ValueString(),
496+
AutoDiscoveryEnabled: state.AutoDiscoveryEnabled.ValueBool(),
488497
}
489498

490499
err = r.client.CreateSubscription(body)
@@ -529,6 +538,7 @@ func (r *CAMConnectorResource) Read(ctx context.Context, req resource.ReadReques
529538
IsTFProviderDeployed: true,
530539
Features: stateFeatures,
531540
FeaturesConfigFilePath: state.FeaturesConfigFilePath.ValueString(),
541+
AutoDiscoveryEnabled: state.AutoDiscoveryEnabled.ValueBool(),
532542
}
533543

534544
err = r.client.UpdateSubscription(res.SubscriptionID, body)
@@ -703,6 +713,7 @@ func (r *CAMConnectorResource) Update(ctx context.Context, req resource.UpdateRe
703713
IsTFProviderDeployed: true,
704714
Features: features,
705715
FeaturesConfigFilePath: plan.FeaturesConfigFilePath.ValueString(),
716+
AutoDiscoveryEnabled: plan.AutoDiscoveryEnabled.ValueBool(),
706717
}
707718

708719
err := r.client.UpdateSubscription(subscriptionID, body)
@@ -768,6 +779,7 @@ func (r *CAMConnectorResource) Update(ctx context.Context, req resource.UpdateRe
768779
state.FeaturesConfigFilePath = plan.FeaturesConfigFilePath
769780
// Preserve prevent_destroy from plan since API does not return it
770781
state.PreventDestroy = plan.PreventDestroy
782+
state.AutoDiscoveryEnabled = plan.AutoDiscoveryEnabled
771783
}
772784

773785
resp.State.Set(ctx, &state)

0 commit comments

Comments
 (0)