Skip to content

Commit 3b544ed

Browse files
author
ccushing
committed
Add customer secret key enhancements
1 parent 944a92f commit 3b544ed

File tree

8 files changed

+664
-19
lines changed

8 files changed

+664
-19
lines changed

docs/examples/identity/user.tf

Lines changed: 45 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,39 @@
11
/*
2-
* This example file shows how to create a user, add an api key, and output their password.
2+
* This example file shows how to create a user, add an api key, define swift keys and customer secret keys.
33
*/
44

55
resource "oci_identity_user" "user1" {
66
name = "tf-example-user"
77
description = "user created by terraform"
88
}
99

10+
data "oci_identity_users" "users1" {
11+
compartment_id = "${oci_identity_user.user1.compartment_id}"
12+
filter {
13+
name = "name"
14+
values = ["tf-example-user"]
15+
}
16+
}
17+
18+
output "users1" {
19+
value = "${data.oci_identity_users.users1.users}"
20+
}
21+
22+
1023
resource "oci_identity_ui_password" "password1" {
1124
user_id = "${oci_identity_user.user1.id}"
1225
}
1326

27+
output "user-password" {
28+
sensitive = false
29+
value = "${oci_identity_ui_password.password1.password}"
30+
}
31+
32+
1433
resource "oci_identity_api_key" "api-key1" {
1534
user_id = "${oci_identity_user.user1.id}"
16-
key_value =
17-
<<EOF
35+
key_value =
36+
<<EOF
1837
-----BEGIN PUBLIC KEY-----
1938
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAtBLQAGmKJ7tpfzYJyqLG
2039
ZDwHL51+d6T8Z00BnP9CFfzxZZZ48PcYSUHuTyCM8mR5JqYLyH6C8tZ/DKqwxUnc
@@ -27,23 +46,33 @@ fwIDAQAB
2746
EOF
2847
}
2948

30-
data "oci_identity_users" "users1" {
31-
compartment_id = "${oci_identity_user.user1.compartment_id}"
32-
filter {
33-
name = "name"
34-
values = ["tf-example-user"]
35-
}
49+
output "user-api-key" {
50+
value = "${oci_identity_api_key.api-key1.key_value}"
3651
}
3752

38-
output "users1" {
39-
value = "${data.oci_identity_users.users1.users}"
53+
54+
resource "oci_identity_swift_password" "swift-password1" {
55+
user_id = "${oci_identity_user.user1.id}"
56+
description = "user swift password created by terraform"
4057
}
4158

42-
output "user-password" {
43-
sensitive = false
44-
value = "${oci_identity_ui_password.password1.password}"
59+
output "swift-password" {
60+
value = "${oci_identity_swift_password.swift-password1.customer_secret_keys.password}"
4561
}
4662

47-
output "user-api-key" {
48-
value = "${oci_identity_api_key.api-key1.key_value}"
63+
64+
resource "oci_identity_customer_secret_key" "customer-secret-key1" {
65+
user_id = "${oci_identity_user.user1.id}"
66+
display_name = "tf-example-customer-secret-key"
67+
}
68+
69+
data "oci_identity_customer_secret_keys" "customer-secret-keys1" {
70+
user_id = "${oci_identity_user.user1.id}"
71+
}
72+
73+
output "customer-secret-key" {
74+
value = [
75+
"${oci_identity_customer_secret_key.customer-secret-key1.key}",
76+
"${data.oci_identity_customer_secret_keys.customer-secret-keys1.customer_secret_keys}"
77+
]
4978
}
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
# oci_identity_customer_secret_key
2+
3+
## CustomerSecretKey Resource
4+
5+
### CustomerSecretKey Reference
6+
7+
The following attributes are exported:
8+
9+
* `display_name` - The displayName you assign to the secret key. Does not have to be unique, and it's changeable.
10+
* `id` - The OCID of the secret key.
11+
* `inactive_state` - The detailed status of INACTIVE lifecycleState.
12+
* `key` - The secret key.
13+
* `state` - The secret key's current state. After creating a secret key, make sure its `lifecycleState` changes from CREATING to ACTIVE before using it.
14+
* `time_created` - Date and time the `CustomerSecretKey` object was created, in the format defined by RFC3339. Example: `2016-08-25T21:10:29.600Z`
15+
* `time_expires` - Date and time when this password will expire, in the format defined by RFC3339. Null if it never expires. Example: `2016-08-25T21:10:29.600Z`
16+
* `user_id` - The OCID of the user the password belongs to.
17+
18+
19+
20+
### Create Operation
21+
Creates a new secret key for the specified user. Secret keys are used for authentication with the Object Storage Service's Amazon S3
22+
compatible API. For information, see
23+
[Managing User Credentials](https://docs.us-phoenix-1.oraclecloud.com/Content/Identity/Tasks/managingcredentials.htm).
24+
25+
You must specify a *description* for the secret key (although it can be an empty string). It does not
26+
have to be unique, and you can change it anytime with
27+
[UpdateCustomerSecretKey](https://docs.us-phoenix-1.oraclecloud.com/api/#/en/identity/20160918/CustomerSecretKeySummary/UpdateCustomerSecretKey).
28+
29+
Every user has permission to create a secret key for *their own user ID*. An administrator in your organization
30+
does not need to write a policy to give users this ability. To compare, administrators who have permission to the
31+
tenancy can use this operation to create a secret key for any user, including themselves.
32+
33+
34+
The following arguments are supported:
35+
36+
* `display_name` - (Required) The name you assign to the secret key during creation. Does not have to be unique, and it's changeable.
37+
* `user_id` - (Required) The OCID of the user.
38+
39+
40+
### Update Operation
41+
42+
43+
The following arguments support updates:
44+
* `display_name` - The name you assign to the secret key during creation. Does not have to be unique, and it's changeable.
45+
46+
** IMPORTANT **
47+
Any change to a property that does not support update will force the destruction and recreation of the resource with the new property values
48+
49+
### Example Usage
50+
51+
```
52+
resource "oci_identity_customer_secret_key" "test_customer_secret_key" {
53+
#Required
54+
display_name = "${var.customer_secret_key_display_name}"
55+
user_id = "${oci_identity_user.test_user.id}"
56+
}
57+
```
58+
59+
# oci_identity_customer_secret_keys
60+
61+
## CustomerSecretKey DataSource
62+
63+
Gets a list of customer_secret_keys.
64+
65+
### List Operation
66+
Lists the secret keys for the specified user. The returned object contains the secret key's OCID, but not
67+
the secret key itself. The actual secret key is returned only upon creation.
68+
69+
The following arguments are supported:
70+
71+
* `user_id` - (Required) The OCID of the user.
72+
73+
74+
The following attributes are exported:
75+
76+
* `customer_secret_keys` - The list of customer_secret_keys.
77+
78+
### Example Usage
79+
80+
```
81+
data "oci_identity_customer_secret_keys" "test_customer_secret_keys" {
82+
#Required
83+
user_id = "${oci_identity_user.test_user.id}"
84+
}
85+
```

docs/identity/users.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ Any change to a property that does not support update will force the destruction
7676
```
7777
resource "oci_identity_user" "test_user" {
7878
#Required
79-
compartment_id = "${var.compartment_id}"
79+
compartment_id = "${var.tenancy_ocid}"
8080
description = "${var.user_description}"
8181
name = "${var.user_name}"
8282
}
@@ -107,6 +107,6 @@ The following attributes are exported:
107107
```
108108
data "oci_identity_users" "test_users" {
109109
#Required
110-
compartment_id = "${var.compartment_id}"
110+
compartment_id = "${var.tenancy_ocid}"
111111
}
112112
```

0 commit comments

Comments
 (0)