Skip to content

Commit 0fcf55a

Browse files
committed
Update roles
1 parent cad58e3 commit 0fcf55a

File tree

3 files changed

+88
-17
lines changed

3 files changed

+88
-17
lines changed

modules/alicloud/vendor-access/files/access_policy.json.tpl

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,19 @@
209209
"Resource": [
210210
"*"
211211
]
212+
},
213+
{
214+
"Effect": "Allow",
215+
"Action": [
216+
"oss:Get*",
217+
"oss:List*",
218+
"oss:Delete*",
219+
"oss:Put*",
220+
"oss:Restore*"
221+
],
222+
"Resource": [
223+
"*"
224+
]
212225
}
213226
]
214227
}

modules/alicloud/vendor-access/main.tf

Lines changed: 63 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,33 +8,72 @@ locals {
88
data "alicloud_caller_identity" "current" {
99
}
1010

11+
data "alicloud_ram_policy_document" "cloud_manager_trust_policy" {
12+
version = "1"
13+
statement {
14+
effect = "Allow"
15+
action = ["sts:AssumeRole"]
16+
principal {
17+
entity = "RAM"
18+
identifiers = var.streamnative_cloud_manager_role_arns
19+
}
20+
condition {
21+
operator = "StringEquals"
22+
variable = "sts:ExternalId"
23+
values = var.organization_ids
24+
}
25+
}
26+
}
27+
28+
resource "alicloud_ram_policy" "cloud_manager_access" {
29+
policy_name = "streamnative-bootstrap"
30+
description = "StreamNative cloud manager access policy"
31+
policy_document = local.access_policy_document
32+
force = true
33+
rotate_strategy = "DeleteOldestNonDefaultVersionWhenLimitExceeded"
34+
}
35+
36+
resource "alicloud_ram_role" "cloud_manager_role" {
37+
name = "streamnative-bootstrap"
38+
description = "StreamNative cloud manager access role"
39+
document = data.alicloud_ram_policy_document.cloud_manager_trust_policy.document
40+
force = true
41+
}
42+
43+
resource "alicloud_ram_role_policy_attachment" "cloud_manager_access" {
44+
policy_name = alicloud_ram_policy.cloud_manager_access.policy_name
45+
policy_type = alicloud_ram_policy.cloud_manager_access.type
46+
role_name = alicloud_ram_role.cloud_manager_role.name
47+
}
48+
49+
1150
data "alicloud_ram_policy_document" "support_role_trust_policy" {
1251
version = "1"
1352
statement {
1453
effect = "Allow"
1554
action = ["sts:AssumeRole"]
1655
principal {
17-
entity = "RAM"
18-
identifiers = var.streamnative_support_access_role_arns
56+
entity = "RAM"
57+
identifiers = var.streamnative_support_role_arns
1958
}
2059
condition {
2160
operator = "StringEquals"
2261
variable = "sts:ExternalId"
23-
values = [var.organization_id]
62+
values = var.organization_ids
2463
}
2564
}
2665
}
2766

2867
resource "alicloud_ram_policy" "support_access" {
29-
policy_name = "StreamNativeSupportAccess"
30-
description = "StreamNative support access policy"
68+
policy_name = "streamnative-support"
69+
description = "StreamNative support role access policy"
3170
policy_document = local.access_policy_document
3271
force = true
3372
rotate_strategy = "DeleteOldestNonDefaultVersionWhenLimitExceeded"
3473
}
3574

36-
resource "alicloud_ram_role" "support_access_role" {
37-
name = "StreamNativeSupportAccessRole"
75+
resource "alicloud_ram_role" "support_role" {
76+
name = "streamnative-support"
3877
description = "StreamNative support access role"
3978
document = data.alicloud_ram_policy_document.support_role_trust_policy.document
4079
force = true
@@ -43,23 +82,35 @@ resource "alicloud_ram_role" "support_access_role" {
4382
resource "alicloud_ram_role_policy_attachment" "support_access" {
4483
policy_name = alicloud_ram_policy.support_access.policy_name
4584
policy_type = alicloud_ram_policy.support_access.type
46-
role_name = alicloud_ram_role.support_access_role.name
85+
role_name = alicloud_ram_role.support_role.name
4786
}
4887

4988

89+
// Activate OSS
90+
data "alicloud_oss_service" "open" {
91+
enable = "On"
92+
}
93+
5094
// Activate ACK
5195
// ref: https://www.alibabacloud.com/help/en/ack/ack-managed-and-ack-dedicated/developer-reference/use-terraform-to-assign-default-roles-to-ack-when-you-use-ack-for-the-first-time
5296
data "alicloud_ack_service" "open" {
53-
enable = "On"
54-
type = "propayasgo"
97+
enable = "On"
98+
type = "propayasgo"
5599
}
56100

57101
output "account_id" {
58102
value = data.alicloud_caller_identity.current.account_id
59103
}
60104

61-
output "organization_id" {
62-
value = var.organization_id
105+
output "organization_ids" {
106+
value = var.organization_ids
107+
}
108+
109+
output "services" {
110+
value = {
111+
oss = data.alicloud_oss_service.open.status
112+
ack = data.alicloud_ack_service.open.status
113+
}
63114
}
64115

65116

modules/alicloud/vendor-access/variables.tf

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,27 @@ variable "sn_policy_version" {
22
default = ""
33
}
44

5-
variable "organization_id" {
5+
variable "organization_ids" {
66
description = "The ID of your organization on StreamNative Cloud."
7-
type = string
7+
type = list(string)
88
}
99

1010
variable "region" {
1111
default = "*"
1212
description = "The aliyun region where your StreamNative Cloud Environment can be deployed. Defaults to all regions."
1313
}
1414

15+
variable "streamnative_cloud_manager_role_arns" {
16+
default = ["acs:ram::5855446584058772:role/cloud-manager"]
17+
description = "The list of StreamNative cloud manager role ARNs. This is used to grant StreamNative cloud manager to your environment."
18+
type = list(string)
19+
}
20+
21+
1522

16-
variable "streamnative_support_access_role_arns" {
17-
default = ["acs:ram::5855446584058772:role/streamnativesupport"]
18-
description = "The list of StreamNative support access role ARNs. This is used to grant StreamNative support access to your environment."
23+
variable "streamnative_support_role_arns" {
24+
default = ["acs:ram::5855446584058772:role/support-general"]
25+
description = "The list of StreamNative support role ARNs. This is used to grant StreamNative support to your environment."
1926
type = list(string)
2027
}
2128

0 commit comments

Comments
 (0)