Skip to content

Commit 21d3fb5

Browse files
authored
feat(account): add support for project in SSH key (#603)
1 parent 3ee3973 commit 21d3fb5

File tree

4 files changed

+12
-3
lines changed

4 files changed

+12
-3
lines changed

docs/data-sources/account_ssh_key.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ data "scaleway_account_ssh_key" "my_key" {
2626

2727
- `name` - The SSH key name. Only one of `name` and `ssh_key_id` should be specified.
2828
- `ssh_key_id` - The SSH key id. Only one of `name` and `ssh_key_id` should be specified.
29-
- `organization_id` - (Defaults to [provider](../index.md#organization_id) `organization_id`) The ID of the organization the server is associated with.
29+
- `organization_id` - (Defaults to [provider](../index.md#organization_id) `organization_id`) The ID of the organization the SSH key is associated with.
30+
- `project_id` - (Defaults to [provider](../index.md#project_id) `project_id`) The ID of the project the SSH key is associated with.
3031

3132

3233
## Attributes Reference

docs/resources/account_ssh_key.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ The following arguments are supported:
2323

2424
- `name` - (Required) The name of the SSH key.
2525
- `public_key` - (Required) The public SSH key to be added.
26-
- `organization_id` - (Defaults to [provider](../index.md#organization_id) `organization_id`) The ID of the organization the IP is associated with.
26+
- `organization_id` - (Defaults to [provider](../index.md#organization_id) `organization_id`) The ID of the organization the SSH key is associated with.
27+
- `project_id` - (Defaults to [provider](../index.md#project_id) `project_id`) The ID of the project the SSH key is associated with.
2728

2829
## Attributes Reference
2930

scaleway/data_source_account_ssh_key.go

+5-1
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ func dataSourceScalewayAccountSSHKey() *schema.Resource {
3333
Description: "The public SSH key",
3434
},
3535
"organization_id": organizationIDSchema(),
36+
"project_id": projectIDSchema(),
3637
},
3738
}
3839
}
@@ -50,7 +51,9 @@ func dataSourceScalewayAccountSSHKeyRead(ctx context.Context, d *schema.Resource
5051
sshKey = res
5152
} else {
5253
res, err := accountAPI.ListSSHKeys(&account.ListSSHKeysRequest{
53-
Name: expandStringPtr(d.Get("name")),
54+
Name: expandStringPtr(d.Get("name")),
55+
OrganizationID: expandStringPtr(d.Get("organization_id")),
56+
ProjectID: expandStringPtr(d.Get("project_id")),
5457
}, scw.WithContext(ctx))
5558
if err != nil {
5659
return diag.FromErr(err)
@@ -69,6 +72,7 @@ func dataSourceScalewayAccountSSHKeyRead(ctx context.Context, d *schema.Resource
6972
_ = d.Set("ssh_key_id", sshKey.ID)
7073
_ = d.Set("public_key", sshKey.PublicKey)
7174
_ = d.Set("organization_id", sshKey.OrganizationID)
75+
_ = d.Set("project_id", sshKey.ProjectID)
7276

7377
return nil
7478
}

scaleway/resource_account_ssh_key.go

+3
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ func resourceScalewayAccountSSKKey() *schema.Resource {
3636
},
3737
},
3838
"organization_id": organizationIDSchema(),
39+
"project_id": projectIDSchema(),
3940
},
4041
}
4142
}
@@ -47,6 +48,7 @@ func resourceScalewayAccountSSHKeyCreate(ctx context.Context, d *schema.Resource
4748
Name: d.Get("name").(string),
4849
PublicKey: strings.Trim(d.Get("public_key").(string), "\n"),
4950
OrganizationID: expandStringPtr(d.Get("organization_id")),
51+
ProjectID: expandStringPtr(d.Get("project_id")),
5052
}, scw.WithContext(ctx))
5153
if err != nil {
5254
return diag.FromErr(err)
@@ -74,6 +76,7 @@ func resourceScalewayAccountSSHKeyRead(ctx context.Context, d *schema.ResourceDa
7476
_ = d.Set("name", res.Name)
7577
_ = d.Set("public_key", res.PublicKey)
7678
_ = d.Set("organization_id", res.OrganizationID)
79+
_ = d.Set("project_id", res.ProjectID)
7780

7881
return nil
7982
}

0 commit comments

Comments
 (0)