Skip to content

Commit bbc1bf6

Browse files
sameer-iniru
andauthored
feature(cloud-account): adds workload identity alias field (#242)
* adding wip alias field * fixing test Co-authored-by: iru <irune.prado@sysdig.com>
1 parent d08dfa5 commit bbc1bf6

File tree

4 files changed

+26
-14
lines changed

4 files changed

+26
-14
lines changed

sysdig/internal/client/secure/models.go

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -366,13 +366,14 @@ func VulnerabilityExceptionFromJSON(body []byte) *VulnerabilityException {
366366
// -------- CloudAccount --------
367367

368368
type CloudAccount struct {
369-
AccountID string `json:"accountId"`
370-
Provider string `json:"provider"`
371-
Alias string `json:"alias"`
372-
RoleAvailable bool `json:"roleAvailable"`
373-
RoleName string `json:"roleName"`
374-
ExternalID string `json:"externalId,omitempty"`
375-
WorkLoadIdentityAccountID string `json:"workloadIdentityAccountId,omitempty"`
369+
AccountID string `json:"accountId"`
370+
Provider string `json:"provider"`
371+
Alias string `json:"alias"`
372+
RoleAvailable bool `json:"roleAvailable"`
373+
RoleName string `json:"roleName"`
374+
ExternalID string `json:"externalId,omitempty"`
375+
WorkLoadIdentityAccountID string `json:"workloadIdentityAccountId,omitempty"`
376+
WorkLoadIdentityAccountAlias string `json:"workLoadIdentityAccountAlias,omitempty"`
376377
}
377378

378379
func (e *CloudAccount) ToJSON() io.Reader {

sysdig/resource_sysdig_secure_cloud_account.go

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,10 @@ func resourceSysdigSecureCloudAccount() *schema.Resource {
6262
Type: schema.TypeString,
6363
Optional: true,
6464
},
65+
"workload_identity_account_alias": {
66+
Type: schema.TypeString,
67+
Optional: true,
68+
},
6569
},
6670
}
6771
}
@@ -85,6 +89,7 @@ func resourceSysdigSecureCloudAccountCreate(ctx context.Context, d *schema.Resou
8589
_ = d.Set("role_name", cloudAccount.RoleName)
8690
_ = d.Set("external_id", cloudAccount.ExternalID)
8791
_ = d.Set("workload_identity_account_id", cloudAccount.WorkLoadIdentityAccountID)
92+
_ = d.Set("workload_identity_account_alias", cloudAccount.WorkLoadIdentityAccountAlias)
8893

8994
return nil
9095
}
@@ -112,6 +117,7 @@ func resourceSysdigSecureCloudAccountRead(ctx context.Context, d *schema.Resourc
112117
_ = d.Set("role_name", cloudAccount.RoleName)
113118
_ = d.Set("external_id", cloudAccount.ExternalID)
114119
_ = d.Set("workload_identity_account_id", cloudAccount.WorkLoadIdentityAccountID)
120+
_ = d.Set("workload_identity_account_alias", cloudAccount.WorkLoadIdentityAccountAlias)
115121

116122
return nil
117123
}
@@ -151,11 +157,12 @@ func resourceSysdigSecureCloudAccountDelete(ctx context.Context, d *schema.Resou
151157

152158
func cloudAccountFromResourceData(d *schema.ResourceData) *secure.CloudAccount {
153159
return &secure.CloudAccount{
154-
AccountID: d.Get("account_id").(string),
155-
Provider: d.Get("cloud_provider").(string),
156-
Alias: d.Get("alias").(string),
157-
RoleAvailable: d.Get("role_enabled").(bool),
158-
RoleName: d.Get("role_name").(string),
159-
WorkLoadIdentityAccountID: d.Get("workload_identity_account_id").(string),
160+
AccountID: d.Get("account_id").(string),
161+
Provider: d.Get("cloud_provider").(string),
162+
Alias: d.Get("alias").(string),
163+
RoleAvailable: d.Get("role_enabled").(bool),
164+
RoleName: d.Get("role_name").(string),
165+
WorkLoadIdentityAccountID: d.Get("workload_identity_account_id").(string),
166+
WorkLoadIdentityAccountAlias: d.Get("workload_identity_account_alias").(string),
160167
}
161168
}

sysdig/resource_sysdig_secure_cloud_account_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ resource "sysdig_secure_cloud_account" "sample-1" {
9898
role_enabled = "false"
9999
role_name = "CustomRoleName"
100100
workload_identity_account_id = "sample-1-%s"
101+
workload_identity_account_alias = "%s"
101102
}
102-
`, accountID, accountID, accountID)
103+
`, accountID, accountID, accountID, accountID)
103104
}

website/docs/r/secure_cloud_account.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ resource "sysdig_secure_cloud_account" "sample" {
2222
role_enabled = "false"
2323
role_name = "CustomRoleName"
2424
workload_identity_account_id = "457345678065"
25+
workload_identity_account_alias = "prod-alias"
2526
}
2627
```
2728

@@ -39,6 +40,8 @@ resource "sysdig_secure_cloud_account" "sample" {
3940

4041
* `workload_identity_account_id` - (Optional) For GCP only. The account id in which workload identity is present for this account in gcp org.
4142

43+
* `workload_identity_account_alias` - (Optional) For GCP only. The alias of workload identity is present for this account in gcp org.
44+
4245
## Attributes Reference
4346

4447
No additional attributes are exported.

0 commit comments

Comments
 (0)