Skip to content

Commit 268ddac

Browse files
LA4AM12ChenHanZhang
authored andcommitted
resource/alicloud_governance_account: Supports a new argument default_domain_name.
1 parent 561e6c0 commit 268ddac

7 files changed

+69
-3
lines changed

alicloud/resource_alicloud_governance_account.go

+20-1
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
// Package alicloud. This file is generated automatically. Please do not modify it manually, thank you!
21
package alicloud
32

43
import (
4+
"encoding/json"
55
"fmt"
66
"log"
7+
"regexp"
78
"time"
89

910
util "github.com/alibabacloud-go/tea-utils/service"
@@ -53,6 +54,11 @@ func resourceAliCloudGovernanceAccount() *schema.Resource {
5354
Type: schema.TypeInt,
5455
Optional: true,
5556
},
57+
"default_domain_name": {
58+
Type: schema.TypeString,
59+
Optional: true,
60+
ValidateFunc: StringMatch(regexp.MustCompile("^[A-Za-z0-9_.][A-Za-z0-9_.-]{0,49}[A-Za-z0-9_.].onaliyun.com$"), "The default_domain_name (with suffix) has a maximum length of 64 characters and must end with .onaliyun.com."),
61+
},
5662
"status": {
5763
Type: schema.TypeString,
5864
Computed: true,
@@ -92,6 +98,19 @@ func resourceAliCloudGovernanceAccountCreate(d *schema.ResourceData, meta interf
9298
if v, ok := d.GetOk("payer_account_id"); ok {
9399
request["PayerAccountUid"] = v
94100
}
101+
102+
baselineItemsMaps := make([]interface{}, 0)
103+
if v, ok := d.GetOk("default_domain_name"); ok {
104+
baselineItemConfig := make(map[string]interface{})
105+
baselineItemConfig["DefaultDomainName"] = v
106+
config, _ := json.Marshal(baselineItemConfig)
107+
baselineItem := make(map[string]interface{})
108+
baselineItem["Config"] = string(config)
109+
baselineItem["Name"] = "ACS-BP_ACCOUNT_FACTORY_RAM_DEFAULT_DOMAIN"
110+
baselineItemsMaps = append(baselineItemsMaps, baselineItem)
111+
}
112+
request["BaselineItems"] = baselineItemsMaps
113+
95114
runtime := util.RuntimeOptions{}
96115
runtime.SetAutoretry(true)
97116
wait := incrementalWait(3*time.Second, 5*time.Second)

alicloud/resource_alicloud_governance_account_test.go

+8-2
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ func TestAccAliCloudGovernanceAccount_basic0(t *testing.T) {
2020
testAccCheck := rac.resourceAttrMapUpdateSet()
2121
rand := acctest.RandIntRange(10000, 99999)
2222
name := fmt.Sprintf("tf-testacc%sgovernanceaccount%d", defaultRegionToTest, rand)
23+
defaultDomainName := fmt.Sprintf("%s.onaliyun.com", name)
2324
testAccConfig := resourceTestAccConfigFunc(resourceId, name, AlicloudGovernanceAccountBasicDependence7372)
2425
resource.Test(t, resource.TestCase{
2526
PreCheck: func() {
@@ -37,6 +38,7 @@ func TestAccAliCloudGovernanceAccount_basic0(t *testing.T) {
3738
"display_name": name,
3839
"account_name_prefix": name,
3940
"folder_id": "${data.alicloud_resource_manager_folders.default.ids.0}",
41+
"default_domain_name": defaultDomainName,
4042
}),
4143
Check: resource.ComposeTestCheckFunc(
4244
testAccCheck(map[string]string{
@@ -45,14 +47,15 @@ func TestAccAliCloudGovernanceAccount_basic0(t *testing.T) {
4547
"display_name": CHECKSET,
4648
"account_name_prefix": CHECKSET,
4749
"folder_id": CHECKSET,
50+
"default_domain_name": CHECKSET,
4851
}),
4952
),
5053
},
5154
{
5255
ResourceName: resourceId,
5356
ImportState: true,
5457
ImportStateVerify: true,
55-
ImportStateVerifyIgnore: []string{"account_name_prefix", "display_name", "folder_id", "payer_account_id", "baseline_id"},
58+
ImportStateVerifyIgnore: []string{"account_name_prefix", "display_name", "folder_id", "payer_account_id", "baseline_id", "default_domain_name"},
5659
},
5760
},
5861
})
@@ -69,6 +72,7 @@ func TestAccAliCloudGovernanceAccount_basic7372(t *testing.T) {
6972
testAccCheck := rac.resourceAttrMapUpdateSet()
7073
rand := acctest.RandIntRange(10000, 99999)
7174
name := fmt.Sprintf("tf-testacc%sgovernanceaccount%d", defaultRegionToTest, rand)
75+
defaultDomainName := fmt.Sprintf("%s.onaliyun.com", name)
7276
testAccConfig := resourceTestAccConfigFunc(resourceId, name, AlicloudGovernanceAccountBasicDependence7372)
7377
resource.Test(t, resource.TestCase{
7478
PreCheck: func() {
@@ -85,6 +89,7 @@ func TestAccAliCloudGovernanceAccount_basic7372(t *testing.T) {
8589
"display_name": name,
8690
"account_name_prefix": name,
8791
"folder_id": "${data.alicloud_resource_manager_folders.default.ids.0}",
92+
"default_domain_name": defaultDomainName,
8893
}),
8994
Check: resource.ComposeTestCheckFunc(
9095
testAccCheck(map[string]string{
@@ -93,6 +98,7 @@ func TestAccAliCloudGovernanceAccount_basic7372(t *testing.T) {
9398
"display_name": CHECKSET,
9499
"account_name_prefix": CHECKSET,
95100
"folder_id": CHECKSET,
101+
"default_domain_name": CHECKSET,
96102
}),
97103
),
98104
},
@@ -110,7 +116,7 @@ func TestAccAliCloudGovernanceAccount_basic7372(t *testing.T) {
110116
ResourceName: resourceId,
111117
ImportState: true,
112118
ImportStateVerify: true,
113-
ImportStateVerifyIgnore: []string{"account_name_prefix", "display_name", "folder_id", "payer_account_id", "baseline_id"},
119+
ImportStateVerifyIgnore: []string{"account_name_prefix", "display_name", "folder_id", "payer_account_id", "baseline_id", "default_domain_name"},
114120
},
115121
},
116122
})

examples/governance/main.tf

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
resource "alicloud_governance_account" "default" {
2+
account_name_prefix = var.account_name_prefix
3+
folder_id = var.folder_id
4+
baseline_id = var.baseline_id
5+
display_name = var.display_name
6+
default_domain_name = var.default_domain_name
7+
}

examples/governance/outputs.tf

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
output "account_id" {
2+
value = alicloud_governance_account.default.id
3+
}
4+
5+
output "status" {
6+
value = alicloud_governance_account.default.status
7+
}
8+

examples/governance/variables.tf

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
variable "account_name_prefix" {
2+
default = "terraform-example-12"
3+
}
4+
5+
variable "display_name" {
6+
default = "terraform-example-7"
7+
}
8+
9+
variable "folder_id" {
10+
default = "fd-blYPI4NZdI"
11+
}
12+
13+
variable "baseline_id" {
14+
default = "afb-bp14xex9ccnlbe8yzmvd"
15+
}
16+
17+
variable "default_domain_name" {
18+
default = "af-tf-domain-test-11.onaliyun.com"
19+
}

examples/governance/versions.tf

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
2+
terraform {
3+
required_version = ">= 0.12"
4+
}

website/docs/r/governance_account.html.markdown

+3
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,9 @@ The following arguments are supported:
8484

8585
If the registration application is applied to an existing account, this parameter does not need to be filled in.
8686
* `payer_account_id` - (Optional) The ID of the billing account. If you leave this parameter empty, the current account is used as the billing account.
87+
* `default_domain_name` - (Optional, Available since v1.231.0) The domain name is used to qualify the login name of RAM users and RAM roles.
88+
89+
Format: \<AccountAlias>.onaliyun.com where \<AccountAlias> is the account alias, and the default value is the Aliyun account ID. The default domain name must end with the .onaliyun.com suffix. The maximum length of the default domain name (including suffix) is 64 characters. It can contain English letters, numbers, English periods (.) , dashes (-) and underscores (_).
8790

8891
## Attributes Reference
8992

0 commit comments

Comments
 (0)