Skip to content

Commit de61a83

Browse files
authored
feat(monitor): ADD new aws monitor provider parameters (#552)
* ADD new aws monitor provider parameters
1 parent 779e9c0 commit de61a83

File tree

3 files changed

+66
-8
lines changed

3 files changed

+66
-8
lines changed

sysdig/internal/client/v2/model.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -925,7 +925,10 @@ type alertV2ChangeWrapper struct {
925925
}
926926

927927
type CloudAccountCredentialsMonitor struct {
928-
AccountId string `json:"accountId"`
928+
AccountId string `json:"accountId"`
929+
RoleName string `json:"roleName"`
930+
SecretKey string `json:"key"`
931+
AccessKeyId string `json:"id"`
929932
}
930933

931934
type CloudAccountMonitor struct {

sysdig/resource_sysdig_monitor_cloud_account.go

Lines changed: 38 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,29 @@ func resourceSysdigMonitorCloudAccount() *schema.Resource {
3737
Required: true,
3838
},
3939
"account_id": {
40-
Type: schema.TypeString,
41-
Required: true,
40+
Type: schema.TypeString,
41+
Required: true,
42+
Sensitive: true,
4243
},
43-
"additional_options": {
44+
"role_name": {
4445
Type: schema.TypeString,
4546
Optional: true,
4647
},
48+
"secret_key": {
49+
Type: schema.TypeString,
50+
Optional: true,
51+
Sensitive: true,
52+
},
53+
"access_key_id": {
54+
Type: schema.TypeString,
55+
Optional: true,
56+
Sensitive: true,
57+
},
58+
"additional_options": {
59+
Type: schema.TypeString,
60+
Optional: true,
61+
Sensitive: true,
62+
},
4763
},
4864
}
4965
}
@@ -140,7 +156,10 @@ func monitorCloudAccountFromResourceData(data *schema.ResourceData) v2.CloudAcco
140156
IntegrationType: data.Get("integration_type").(string),
141157
AdditionalOptions: data.Get("additional_options").(string),
142158
Credentials: v2.CloudAccountCredentialsMonitor{
143-
AccountId: data.Get("account_id").(string),
159+
AccountId: data.Get("account_id").(string),
160+
RoleName: data.Get("role_name").(string),
161+
SecretKey: data.Get("secret_key").(string),
162+
AccessKeyId: data.Get("access_key_id").(string),
144163
},
145164
}
146165
}
@@ -166,5 +185,20 @@ func monitorCloudAccountToResourceData(data *schema.ResourceData, cloudAccount *
166185
return err
167186
}
168187

188+
err = data.Set("role_name", cloudAccount.Credentials.RoleName)
189+
if err != nil {
190+
return err
191+
}
192+
193+
err = data.Set("secret_key", cloudAccount.Credentials.SecretKey)
194+
if err != nil {
195+
return err
196+
}
197+
198+
err = data.Set("access_key_id", cloudAccount.Credentials.AccessKeyId)
199+
if err != nil {
200+
return err
201+
}
202+
169203
return nil
170204
}

website/docs/r/monitor_cloud_account.md

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,39 @@ Creates a Sysdig Monitor Cloud Account for monitoring cloud resources.
1515
## Example Usage
1616

1717
```terraform
18+
// GCP example
1819
resource "sysdig_monitor_cloud_account" "sample" {
1920
cloud_provider = "GCP"
2021
integration_type = "API"
2122
account_id = "gcp_project_id"
2223
}
24+
25+
// AWS example with role delegation
26+
resource "sysdig_monitor_cloud_account" "sample" {
27+
cloud_provider = "AWS"
28+
integration_type = "Metrics Streams"
29+
account_id = "123412341234"
30+
role_name = "SysdigTestRole"
31+
}
32+
33+
// AWS example with secret key
34+
resource "sysdig_monitor_cloud_account" "sample" {
35+
cloud_provider = "AWS"
36+
integration_type = "Metrics Streams"
37+
account_id = "123412341234"
38+
secret_key = "Xxx5XX2xXx/Xxxx+xxXxXXxXxXxxXXxxxXXxXxXx"
39+
access_key_id = "XXXXX33XXXX3XX3XXX7X"
40+
}
2341
```
2442

2543
## Argument Reference
2644

27-
* `cloud_provider` - (Required) Cloud platform that will be monitored. Only `GCP` is currently supported.
28-
* `integration_type` - (Required) Type of cloud integration. Only `API` is currently supported.
29-
* `account_id` - (Required) The GCP project id for the project that will be monitored.
45+
* `cloud_provider` - (Required) Cloud platform that will be monitored. Only `GCP` and `AWS` are currently supported.
46+
* `integration_type` - (Required) Type of cloud integration. Only `API` and `Metrics Streams` are currently supported (`Metrics Streams` only for `AWS`).
47+
* `account_id` - (Required for GCP) The GCP project id for the project that will be monitored . (Optional For AWS) This identified the target Account ID. If provided, a role_name must be set.
48+
* `role_name` - (Optional) The role name used for delegation over the customer resources towards the Sysdig AWS account. Only for AWS when the authentication mode is role delegation instead of secret key.
49+
* `secret_key` - (Optional) The the secret key for a AWS connection. It must be provided along `access_key_id` when this auth mode is used.
50+
* `access_key_id` - (Optional) The ID for the access key that has the permissions into the Cloud Account. It must be provided along `secret_key` when this auth mode is used.
3051
* `additional_options` - (Optional) The private key generated when creating a new GCP service account key. Must be in JSON format and base64 encoded.
3152

3253
## Attributes Reference

0 commit comments

Comments
 (0)