tencentcloud.CamUserPolicyAttachment
Explore with Pulumi AI
Provides a resource to create a CAM user policy attachment.
Example Usage
import * as pulumi from "@pulumi/pulumi";
import * as tencentcloud from "@pulumi/tencentcloud";
const config = new pulumi.Config();
const camUserBasic = config.get("camUserBasic") || "keep-cam-user";
const policyBasic = new tencentcloud.CamPolicy("policyBasic", {
document: JSON.stringify({
version: "2.0",
statement: [
{
action: ["cos:*"],
resource: ["*"],
effect: "allow",
},
{
effect: "allow",
action: [
"monitor:*",
"cam:ListUsersForGroup",
"cam:ListGroups",
"cam:GetGroup",
],
resource: ["*"],
},
],
}),
description: "tf_test",
});
const users = tencentcloud.getCamUsers({
name: camUserBasic,
});
const userPolicyAttachmentBasic = new tencentcloud.CamUserPolicyAttachment("userPolicyAttachmentBasic", {
userName: users.then(users => users.userLists?.[0]?.userId),
policyId: policyBasic.camPolicyId,
});
import pulumi
import json
import pulumi_tencentcloud as tencentcloud
config = pulumi.Config()
cam_user_basic = config.get("camUserBasic")
if cam_user_basic is None:
cam_user_basic = "keep-cam-user"
policy_basic = tencentcloud.CamPolicy("policyBasic",
document=json.dumps({
"version": "2.0",
"statement": [
{
"action": ["cos:*"],
"resource": ["*"],
"effect": "allow",
},
{
"effect": "allow",
"action": [
"monitor:*",
"cam:ListUsersForGroup",
"cam:ListGroups",
"cam:GetGroup",
],
"resource": ["*"],
},
],
}),
description="tf_test")
users = tencentcloud.get_cam_users(name=cam_user_basic)
user_policy_attachment_basic = tencentcloud.CamUserPolicyAttachment("userPolicyAttachmentBasic",
user_name=users.user_lists[0].user_id,
policy_id=policy_basic.cam_policy_id)
package main
import (
"encoding/json"
"github.com/pulumi/pulumi-terraform-provider/sdks/go/tencentcloud/tencentcloud"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi/config"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
cfg := config.New(ctx, "")
camUserBasic := "keep-cam-user"
if param := cfg.Get("camUserBasic"); param != "" {
camUserBasic = param
}
tmpJSON0, err := json.Marshal(map[string]interface{}{
"version": "2.0",
"statement": []map[string]interface{}{
map[string]interface{}{
"action": []string{
"cos:*",
},
"resource": []string{
"*",
},
"effect": "allow",
},
map[string]interface{}{
"effect": "allow",
"action": []string{
"monitor:*",
"cam:ListUsersForGroup",
"cam:ListGroups",
"cam:GetGroup",
},
"resource": []string{
"*",
},
},
},
})
if err != nil {
return err
}
json0 := string(tmpJSON0)
policyBasic, err := tencentcloud.NewCamPolicy(ctx, "policyBasic", &tencentcloud.CamPolicyArgs{
Document: pulumi.String(json0),
Description: pulumi.String("tf_test"),
})
if err != nil {
return err
}
users, err := tencentcloud.GetCamUsers(ctx, &tencentcloud.GetCamUsersArgs{
Name: pulumi.StringRef(camUserBasic),
}, nil)
if err != nil {
return err
}
_, err = tencentcloud.NewCamUserPolicyAttachment(ctx, "userPolicyAttachmentBasic", &tencentcloud.CamUserPolicyAttachmentArgs{
UserName: pulumi.String(users.UserLists[0].UserId),
PolicyId: policyBasic.CamPolicyId,
})
if err != nil {
return err
}
return nil
})
}
using System.Collections.Generic;
using System.Linq;
using System.Text.Json;
using Pulumi;
using Tencentcloud = Pulumi.Tencentcloud;
return await Deployment.RunAsync(() =>
{
var config = new Config();
var camUserBasic = config.Get("camUserBasic") ?? "keep-cam-user";
var policyBasic = new Tencentcloud.CamPolicy("policyBasic", new()
{
Document = JsonSerializer.Serialize(new Dictionary<string, object?>
{
["version"] = "2.0",
["statement"] = new[]
{
new Dictionary<string, object?>
{
["action"] = new[]
{
"cos:*",
},
["resource"] = new[]
{
"*",
},
["effect"] = "allow",
},
new Dictionary<string, object?>
{
["effect"] = "allow",
["action"] = new[]
{
"monitor:*",
"cam:ListUsersForGroup",
"cam:ListGroups",
"cam:GetGroup",
},
["resource"] = new[]
{
"*",
},
},
},
}),
Description = "tf_test",
});
var users = Tencentcloud.GetCamUsers.Invoke(new()
{
Name = camUserBasic,
});
var userPolicyAttachmentBasic = new Tencentcloud.CamUserPolicyAttachment("userPolicyAttachmentBasic", new()
{
UserName = users.Apply(getCamUsersResult => getCamUsersResult.UserLists[0]?.UserId),
PolicyId = policyBasic.CamPolicyId,
});
});
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.tencentcloud.CamPolicy;
import com.pulumi.tencentcloud.CamPolicyArgs;
import com.pulumi.tencentcloud.TencentcloudFunctions;
import com.pulumi.tencentcloud.inputs.GetCamUsersArgs;
import com.pulumi.tencentcloud.CamUserPolicyAttachment;
import com.pulumi.tencentcloud.CamUserPolicyAttachmentArgs;
import static com.pulumi.codegen.internal.Serialization.*;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;
public class App {
public static void main(String[] args) {
Pulumi.run(App::stack);
}
public static void stack(Context ctx) {
final var config = ctx.config();
final var camUserBasic = config.get("camUserBasic").orElse("keep-cam-user");
var policyBasic = new CamPolicy("policyBasic", CamPolicyArgs.builder()
.document(serializeJson(
jsonObject(
jsonProperty("version", "2.0"),
jsonProperty("statement", jsonArray(
jsonObject(
jsonProperty("action", jsonArray("cos:*")),
jsonProperty("resource", jsonArray("*")),
jsonProperty("effect", "allow")
),
jsonObject(
jsonProperty("effect", "allow"),
jsonProperty("action", jsonArray(
"monitor:*",
"cam:ListUsersForGroup",
"cam:ListGroups",
"cam:GetGroup"
)),
jsonProperty("resource", jsonArray("*"))
)
))
)))
.description("tf_test")
.build());
final var users = TencentcloudFunctions.getCamUsers(GetCamUsersArgs.builder()
.name(camUserBasic)
.build());
var userPolicyAttachmentBasic = new CamUserPolicyAttachment("userPolicyAttachmentBasic", CamUserPolicyAttachmentArgs.builder()
.userName(users.applyValue(getCamUsersResult -> getCamUsersResult.userLists()[0].userId()))
.policyId(policyBasic.camPolicyId())
.build());
}
}
configuration:
camUserBasic:
type: string
default: keep-cam-user
resources:
policyBasic:
type: tencentcloud:CamPolicy
properties:
document:
fn::toJSON:
version: '2.0'
statement:
- action:
- cos:*
resource:
- '*'
effect: allow
- effect: allow
action:
- monitor:*
- cam:ListUsersForGroup
- cam:ListGroups
- cam:GetGroup
resource:
- '*'
description: tf_test
userPolicyAttachmentBasic:
type: tencentcloud:CamUserPolicyAttachment
properties:
userName: ${users.userLists[0].userId}
policyId: ${policyBasic.camPolicyId}
variables:
users:
fn::invoke:
function: tencentcloud:getCamUsers
arguments:
name: ${camUserBasic}
Create CamUserPolicyAttachment Resource
Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.
Constructor syntax
new CamUserPolicyAttachment(name: string, args: CamUserPolicyAttachmentArgs, opts?: CustomResourceOptions);
@overload
def CamUserPolicyAttachment(resource_name: str,
args: CamUserPolicyAttachmentArgs,
opts: Optional[ResourceOptions] = None)
@overload
def CamUserPolicyAttachment(resource_name: str,
opts: Optional[ResourceOptions] = None,
policy_id: Optional[str] = None,
cam_user_policy_attachment_id: Optional[str] = None,
user_id: Optional[str] = None,
user_name: Optional[str] = None)
func NewCamUserPolicyAttachment(ctx *Context, name string, args CamUserPolicyAttachmentArgs, opts ...ResourceOption) (*CamUserPolicyAttachment, error)
public CamUserPolicyAttachment(string name, CamUserPolicyAttachmentArgs args, CustomResourceOptions? opts = null)
public CamUserPolicyAttachment(String name, CamUserPolicyAttachmentArgs args)
public CamUserPolicyAttachment(String name, CamUserPolicyAttachmentArgs args, CustomResourceOptions options)
type: tencentcloud:CamUserPolicyAttachment
properties: # The arguments to resource properties.
options: # Bag of options to control resource's behavior.
Parameters
- name string
- The unique name of the resource.
- args CamUserPolicyAttachmentArgs
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
- resource_name str
- The unique name of the resource.
- args CamUserPolicyAttachmentArgs
- The arguments to resource properties.
- opts ResourceOptions
- Bag of options to control resource's behavior.
- ctx Context
- Context object for the current deployment.
- name string
- The unique name of the resource.
- args CamUserPolicyAttachmentArgs
- The arguments to resource properties.
- opts ResourceOption
- Bag of options to control resource's behavior.
- name string
- The unique name of the resource.
- args CamUserPolicyAttachmentArgs
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
- name String
- The unique name of the resource.
- args CamUserPolicyAttachmentArgs
- The arguments to resource properties.
- options CustomResourceOptions
- Bag of options to control resource's behavior.
CamUserPolicyAttachment Resource Properties
To learn more about resource properties and how to use them, see Inputs and Outputs in the Architecture and Concepts docs.
Inputs
In Python, inputs that are objects can be passed either as argument classes or as dictionary literals.
The CamUserPolicyAttachment resource accepts the following input properties:
- Policy
Id string - ID of the policy.
- Cam
User stringPolicy Attachment Id - ID of the resource.
- User
Id string - It has been deprecated from version 1.59.5. Use
user_name
instead. ID of the attached CAM user. - User
Name string - Name of the attached CAM user as uniq key.
- Policy
Id string - ID of the policy.
- Cam
User stringPolicy Attachment Id - ID of the resource.
- User
Id string - It has been deprecated from version 1.59.5. Use
user_name
instead. ID of the attached CAM user. - User
Name string - Name of the attached CAM user as uniq key.
- policy
Id String - ID of the policy.
- cam
User StringPolicy Attachment Id - ID of the resource.
- user
Id String - It has been deprecated from version 1.59.5. Use
user_name
instead. ID of the attached CAM user. - user
Name String - Name of the attached CAM user as uniq key.
- policy
Id string - ID of the policy.
- cam
User stringPolicy Attachment Id - ID of the resource.
- user
Id string - It has been deprecated from version 1.59.5. Use
user_name
instead. ID of the attached CAM user. - user
Name string - Name of the attached CAM user as uniq key.
- policy_
id str - ID of the policy.
- cam_
user_ strpolicy_ attachment_ id - ID of the resource.
- user_
id str - It has been deprecated from version 1.59.5. Use
user_name
instead. ID of the attached CAM user. - user_
name str - Name of the attached CAM user as uniq key.
- policy
Id String - ID of the policy.
- cam
User StringPolicy Attachment Id - ID of the resource.
- user
Id String - It has been deprecated from version 1.59.5. Use
user_name
instead. ID of the attached CAM user. - user
Name String - Name of the attached CAM user as uniq key.
Outputs
All input properties are implicitly available as output properties. Additionally, the CamUserPolicyAttachment resource produces the following output properties:
- Create
Mode double - Mode of Creation of the CAM user policy attachment.
1
means the CAM policy attachment is created by production, and the others indicate syntax strategy ways. - Create
Time string - Create time of the CAM user policy attachment.
- Id string
- The provider-assigned unique ID for this managed resource.
- Policy
Name string - Name of the policy.
- Policy
Type string - Type of the policy strategy.
User
means customer strategy andQCS
means preset strategy.
- Create
Mode float64 - Mode of Creation of the CAM user policy attachment.
1
means the CAM policy attachment is created by production, and the others indicate syntax strategy ways. - Create
Time string - Create time of the CAM user policy attachment.
- Id string
- The provider-assigned unique ID for this managed resource.
- Policy
Name string - Name of the policy.
- Policy
Type string - Type of the policy strategy.
User
means customer strategy andQCS
means preset strategy.
- create
Mode Double - Mode of Creation of the CAM user policy attachment.
1
means the CAM policy attachment is created by production, and the others indicate syntax strategy ways. - create
Time String - Create time of the CAM user policy attachment.
- id String
- The provider-assigned unique ID for this managed resource.
- policy
Name String - Name of the policy.
- policy
Type String - Type of the policy strategy.
User
means customer strategy andQCS
means preset strategy.
- create
Mode number - Mode of Creation of the CAM user policy attachment.
1
means the CAM policy attachment is created by production, and the others indicate syntax strategy ways. - create
Time string - Create time of the CAM user policy attachment.
- id string
- The provider-assigned unique ID for this managed resource.
- policy
Name string - Name of the policy.
- policy
Type string - Type of the policy strategy.
User
means customer strategy andQCS
means preset strategy.
- create_
mode float - Mode of Creation of the CAM user policy attachment.
1
means the CAM policy attachment is created by production, and the others indicate syntax strategy ways. - create_
time str - Create time of the CAM user policy attachment.
- id str
- The provider-assigned unique ID for this managed resource.
- policy_
name str - Name of the policy.
- policy_
type str - Type of the policy strategy.
User
means customer strategy andQCS
means preset strategy.
- create
Mode Number - Mode of Creation of the CAM user policy attachment.
1
means the CAM policy attachment is created by production, and the others indicate syntax strategy ways. - create
Time String - Create time of the CAM user policy attachment.
- id String
- The provider-assigned unique ID for this managed resource.
- policy
Name String - Name of the policy.
- policy
Type String - Type of the policy strategy.
User
means customer strategy andQCS
means preset strategy.
Look up Existing CamUserPolicyAttachment Resource
Get an existing CamUserPolicyAttachment resource’s state with the given name, ID, and optional extra properties used to qualify the lookup.
public static get(name: string, id: Input<ID>, state?: CamUserPolicyAttachmentState, opts?: CustomResourceOptions): CamUserPolicyAttachment
@staticmethod
def get(resource_name: str,
id: str,
opts: Optional[ResourceOptions] = None,
cam_user_policy_attachment_id: Optional[str] = None,
create_mode: Optional[float] = None,
create_time: Optional[str] = None,
policy_id: Optional[str] = None,
policy_name: Optional[str] = None,
policy_type: Optional[str] = None,
user_id: Optional[str] = None,
user_name: Optional[str] = None) -> CamUserPolicyAttachment
func GetCamUserPolicyAttachment(ctx *Context, name string, id IDInput, state *CamUserPolicyAttachmentState, opts ...ResourceOption) (*CamUserPolicyAttachment, error)
public static CamUserPolicyAttachment Get(string name, Input<string> id, CamUserPolicyAttachmentState? state, CustomResourceOptions? opts = null)
public static CamUserPolicyAttachment get(String name, Output<String> id, CamUserPolicyAttachmentState state, CustomResourceOptions options)
resources: _: type: tencentcloud:CamUserPolicyAttachment get: id: ${id}
- name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- state
- Any extra arguments used during the lookup.
- opts
- A bag of options that control this resource's behavior.
- resource_name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- state
- Any extra arguments used during the lookup.
- opts
- A bag of options that control this resource's behavior.
- name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- state
- Any extra arguments used during the lookup.
- opts
- A bag of options that control this resource's behavior.
- name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- state
- Any extra arguments used during the lookup.
- opts
- A bag of options that control this resource's behavior.
- Cam
User stringPolicy Attachment Id - ID of the resource.
- Create
Mode double - Mode of Creation of the CAM user policy attachment.
1
means the CAM policy attachment is created by production, and the others indicate syntax strategy ways. - Create
Time string - Create time of the CAM user policy attachment.
- Policy
Id string - ID of the policy.
- Policy
Name string - Name of the policy.
- Policy
Type string - Type of the policy strategy.
User
means customer strategy andQCS
means preset strategy. - User
Id string - It has been deprecated from version 1.59.5. Use
user_name
instead. ID of the attached CAM user. - User
Name string - Name of the attached CAM user as uniq key.
- Cam
User stringPolicy Attachment Id - ID of the resource.
- Create
Mode float64 - Mode of Creation of the CAM user policy attachment.
1
means the CAM policy attachment is created by production, and the others indicate syntax strategy ways. - Create
Time string - Create time of the CAM user policy attachment.
- Policy
Id string - ID of the policy.
- Policy
Name string - Name of the policy.
- Policy
Type string - Type of the policy strategy.
User
means customer strategy andQCS
means preset strategy. - User
Id string - It has been deprecated from version 1.59.5. Use
user_name
instead. ID of the attached CAM user. - User
Name string - Name of the attached CAM user as uniq key.
- cam
User StringPolicy Attachment Id - ID of the resource.
- create
Mode Double - Mode of Creation of the CAM user policy attachment.
1
means the CAM policy attachment is created by production, and the others indicate syntax strategy ways. - create
Time String - Create time of the CAM user policy attachment.
- policy
Id String - ID of the policy.
- policy
Name String - Name of the policy.
- policy
Type String - Type of the policy strategy.
User
means customer strategy andQCS
means preset strategy. - user
Id String - It has been deprecated from version 1.59.5. Use
user_name
instead. ID of the attached CAM user. - user
Name String - Name of the attached CAM user as uniq key.
- cam
User stringPolicy Attachment Id - ID of the resource.
- create
Mode number - Mode of Creation of the CAM user policy attachment.
1
means the CAM policy attachment is created by production, and the others indicate syntax strategy ways. - create
Time string - Create time of the CAM user policy attachment.
- policy
Id string - ID of the policy.
- policy
Name string - Name of the policy.
- policy
Type string - Type of the policy strategy.
User
means customer strategy andQCS
means preset strategy. - user
Id string - It has been deprecated from version 1.59.5. Use
user_name
instead. ID of the attached CAM user. - user
Name string - Name of the attached CAM user as uniq key.
- cam_
user_ strpolicy_ attachment_ id - ID of the resource.
- create_
mode float - Mode of Creation of the CAM user policy attachment.
1
means the CAM policy attachment is created by production, and the others indicate syntax strategy ways. - create_
time str - Create time of the CAM user policy attachment.
- policy_
id str - ID of the policy.
- policy_
name str - Name of the policy.
- policy_
type str - Type of the policy strategy.
User
means customer strategy andQCS
means preset strategy. - user_
id str - It has been deprecated from version 1.59.5. Use
user_name
instead. ID of the attached CAM user. - user_
name str - Name of the attached CAM user as uniq key.
- cam
User StringPolicy Attachment Id - ID of the resource.
- create
Mode Number - Mode of Creation of the CAM user policy attachment.
1
means the CAM policy attachment is created by production, and the others indicate syntax strategy ways. - create
Time String - Create time of the CAM user policy attachment.
- policy
Id String - ID of the policy.
- policy
Name String - Name of the policy.
- policy
Type String - Type of the policy strategy.
User
means customer strategy andQCS
means preset strategy. - user
Id String - It has been deprecated from version 1.59.5. Use
user_name
instead. ID of the attached CAM user. - user
Name String - Name of the attached CAM user as uniq key.
Import
CAM user policy attachment can be imported using the id, e.g.
$ pulumi import tencentcloud:index/camUserPolicyAttachment:CamUserPolicyAttachment foo cam-test#26800353
To learn more about importing existing cloud resources, see Importing resources.
Package Details
- Repository
- tencentcloud tencentcloudstack/terraform-provider-tencentcloud
- License
- Notes
- This Pulumi package is based on the
tencentcloud
Terraform Provider.