CodeSample小助手 2020-04-03
provider "alicloud" {
}
resource "alicloud_ram_user" "user" {
name = "user_test"
display_name = "TestAccount"
mobile = "86-18688888888"
email = "example@example.com"
comments = "yoyoyo"
force = true
}
resource "alicloud_ram_login_profile" "profile" {
user_name = alicloud_ram_user.user.name
password = "!Test@123456"
}
resource "alicloud_ram_access_key" "ak" {
user_name = alicloud_ram_user.user.name
secret_file = "accesskey.txt"
}
resource "alicloud_ram_group" "group" {
name = "test_ram_group"
comments = "this is a group comments."
force = true
}
resource "alicloud_ram_group_membership" "membership" {
group_name = alicloud_ram_group.group.name
user_names = [alicloud_ram_user.user.name]
}
module "ram_user" {
// 引用module源地址
source = "terraform-alicloud-modules/ram/alicloud"
// RAM用户名
name = "terraformtest1"
// 是否创建控制台登录凭证
create_ram_user_login_profile = true
// 控制台登录密码
password = "User@123"
// 是否创建accesskey
create_ram_access_key = true
// 是否赋予管理员权限
is_admin = true
}
当create_ram_access_key为true时,会在当前路径下生成文件secret.txt存放密钥信息;is_admin为true时,会自动为用户授予某些管理权限。