Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions sysdig/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ const (
SchemaMonitorCloudMetrics = "monitor_cloud_metrics"
SchemaType = "type"
SchemaInstance = "instance"
SchemaVersion = "version"
SchemaCloudConnectorMetadata = "cloud_connector_metadata"
SchemaTrustedRoleMetadata = "trusted_role_metadata"
SchemaEventBridgeMetadata = "event_bridge_metadata"
Expand Down
7 changes: 7 additions & 0 deletions sysdig/resource_sysdig_secure_cloud_auth_account.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ var (
Type: schema.TypeString,
Required: true,
},
SchemaVersion: {
Type: schema.TypeString,
Optional: true,
},
SchemaCloudConnectorMetadata: {
Type: schema.TypeString,
Optional: true,
Expand Down Expand Up @@ -373,6 +377,8 @@ func constructAccountComponents(data *schema.ResourceData) []*cloudauth.AccountC
component.Type = cloudauth.Component(cloudauth.Component_value[value.(string)])
case SchemaInstance:
component.Instance = value.(string)
case SchemaVersion:
component.Version = value.(string)
case SchemaCloudConnectorMetadata:
component.Metadata = &cloudauth.AccountComponent_CloudConnectorMetadata{CloudConnectorMetadata: &cloudauth.CloudConnectorMetadata{}}
err = protojson.Unmarshal([]byte(value.(string)), component.GetCloudConnectorMetadata())
Expand Down Expand Up @@ -484,6 +490,7 @@ func componentsToResourceData(components []*cloudauth.AccountComponent) []map[st
resourceData := map[string]interface{}{}
resourceData[SchemaType] = component.GetType().String()
resourceData[SchemaInstance] = component.GetInstance()
resourceData[SchemaVersion] = component.GetVersion()

switch component.GetType() {
case cloudauth.Component_COMPONENT_CLOUD_CONNECTOR:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ func cloudauthAccountComponentFromResourceData(data *schema.ResourceData) *v2.Cl
AccountComponent: cloudauth.AccountComponent{
Type: cloudauth.Component(cloudauth.Component_value[data.Get(SchemaType).(string)]),
Instance: data.Get(SchemaInstance).(string),
Version: data.Get(SchemaVersion).(string),
},
}
// XXX: naive but simple approach to read resource data, and check for the metadata schema type passed (only one of the types will be passed)
Expand Down Expand Up @@ -243,6 +244,11 @@ func cloudauthAccountComponentToResourceData(data *schema.ResourceData, cloudAcc
return err
}

err = data.Set(SchemaVersion, cloudAccountComponent.GetVersion())
if err != nil {
return err
}

// XXX: naive but simple approach to read accountComponent object from cloudauth, and check for the metadata proto type (only one of the types will be returned)
// then, populate the respective appropriate metadata schema in resource data.
switch cloudAccountComponent.GetType() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ resource "sysdig_secure_cloud_auth_account_component" "azure_service_principal"
account_id = sysdig_secure_cloud_auth_account.azure_sample.id
type = "COMPONENT_SERVICE_PRINCIPAL"
instance = "secure-posture"
version = "v1.0.0"
service_principal_metadata = jsonencode({
azure = {
active_directory_service_principal = {
Expand Down