tencentcloud.CamRolePolicyAttachment
Explore with Pulumi AI
Provides a resource to create a CAM role policy attachment.
Example Usage
import * as pulumi from "@pulumi/pulumi";
import * as tencentcloud from "@pulumi/tencentcloud";
const config = new pulumi.Config();
const camPolicyBasic = config.get("camPolicyBasic") || "keep-cam-policy";
const camRoleBasic = config.get("camRoleBasic") || "keep-cam-role";
const policy = tencentcloud.getCamPolicies({
name: camPolicyBasic,
});
const roles = tencentcloud.getCamRoles({
name: camRoleBasic,
});
const rolePolicyAttachmentBasic = new tencentcloud.CamRolePolicyAttachment("rolePolicyAttachmentBasic", {
roleId: roles.then(roles => roles.roleLists?.[0]?.roleId),
policyId: policy.then(policy => policy.policyLists?.[0]?.policyId),
});
import pulumi
import pulumi_tencentcloud as tencentcloud
config = pulumi.Config()
cam_policy_basic = config.get("camPolicyBasic")
if cam_policy_basic is None:
cam_policy_basic = "keep-cam-policy"
cam_role_basic = config.get("camRoleBasic")
if cam_role_basic is None:
cam_role_basic = "keep-cam-role"
policy = tencentcloud.get_cam_policies(name=cam_policy_basic)
roles = tencentcloud.get_cam_roles(name=cam_role_basic)
role_policy_attachment_basic = tencentcloud.CamRolePolicyAttachment("rolePolicyAttachmentBasic",
role_id=roles.role_lists[0].role_id,
policy_id=policy.policy_lists[0].policy_id)
package main
import (
"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, "")
camPolicyBasic := "keep-cam-policy"
if param := cfg.Get("camPolicyBasic"); param != "" {
camPolicyBasic = param
}
camRoleBasic := "keep-cam-role"
if param := cfg.Get("camRoleBasic"); param != "" {
camRoleBasic = param
}
policy, err := tencentcloud.GetCamPolicies(ctx, &tencentcloud.GetCamPoliciesArgs{
Name: pulumi.StringRef(camPolicyBasic),
}, nil)
if err != nil {
return err
}
roles, err := tencentcloud.GetCamRoles(ctx, &tencentcloud.GetCamRolesArgs{
Name: pulumi.StringRef(camRoleBasic),
}, nil)
if err != nil {
return err
}
_, err = tencentcloud.NewCamRolePolicyAttachment(ctx, "rolePolicyAttachmentBasic", &tencentcloud.CamRolePolicyAttachmentArgs{
RoleId: pulumi.String(roles.RoleLists[0].RoleId),
PolicyId: pulumi.String(policy.PolicyLists[0].PolicyId),
})
if err != nil {
return err
}
return nil
})
}
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Tencentcloud = Pulumi.Tencentcloud;
return await Deployment.RunAsync(() =>
{
var config = new Config();
var camPolicyBasic = config.Get("camPolicyBasic") ?? "keep-cam-policy";
var camRoleBasic = config.Get("camRoleBasic") ?? "keep-cam-role";
var policy = Tencentcloud.GetCamPolicies.Invoke(new()
{
Name = camPolicyBasic,
});
var roles = Tencentcloud.GetCamRoles.Invoke(new()
{
Name = camRoleBasic,
});
var rolePolicyAttachmentBasic = new Tencentcloud.CamRolePolicyAttachment("rolePolicyAttachmentBasic", new()
{
RoleId = roles.Apply(getCamRolesResult => getCamRolesResult.RoleLists[0]?.RoleId),
PolicyId = policy.Apply(getCamPoliciesResult => getCamPoliciesResult.PolicyLists[0]?.PolicyId),
});
});
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.tencentcloud.TencentcloudFunctions;
import com.pulumi.tencentcloud.inputs.GetCamPoliciesArgs;
import com.pulumi.tencentcloud.inputs.GetCamRolesArgs;
import com.pulumi.tencentcloud.CamRolePolicyAttachment;
import com.pulumi.tencentcloud.CamRolePolicyAttachmentArgs;
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 camPolicyBasic = config.get("camPolicyBasic").orElse("keep-cam-policy");
final var camRoleBasic = config.get("camRoleBasic").orElse("keep-cam-role");
final var policy = TencentcloudFunctions.getCamPolicies(GetCamPoliciesArgs.builder()
.name(camPolicyBasic)
.build());
final var roles = TencentcloudFunctions.getCamRoles(GetCamRolesArgs.builder()
.name(camRoleBasic)
.build());
var rolePolicyAttachmentBasic = new CamRolePolicyAttachment("rolePolicyAttachmentBasic", CamRolePolicyAttachmentArgs.builder()
.roleId(roles.applyValue(getCamRolesResult -> getCamRolesResult.roleLists()[0].roleId()))
.policyId(policy.applyValue(getCamPoliciesResult -> getCamPoliciesResult.policyLists()[0].policyId()))
.build());
}
}
configuration:
camPolicyBasic:
type: string
default: keep-cam-policy
camRoleBasic:
type: string
default: keep-cam-role
resources:
rolePolicyAttachmentBasic:
type: tencentcloud:CamRolePolicyAttachment
properties:
roleId: ${roles.roleLists[0].roleId}
policyId: ${policy.policyLists[0].policyId}
variables:
policy:
fn::invoke:
function: tencentcloud:getCamPolicies
arguments:
name: ${camPolicyBasic}
roles:
fn::invoke:
function: tencentcloud:getCamRoles
arguments:
name: ${camRoleBasic}
Create CamRolePolicyAttachment Resource
Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.
Constructor syntax
new CamRolePolicyAttachment(name: string, args: CamRolePolicyAttachmentArgs, opts?: CustomResourceOptions);
@overload
def CamRolePolicyAttachment(resource_name: str,
args: CamRolePolicyAttachmentArgs,
opts: Optional[ResourceOptions] = None)
@overload
def CamRolePolicyAttachment(resource_name: str,
opts: Optional[ResourceOptions] = None,
policy_id: Optional[str] = None,
role_id: Optional[str] = None,
cam_role_policy_attachment_id: Optional[str] = None)
func NewCamRolePolicyAttachment(ctx *Context, name string, args CamRolePolicyAttachmentArgs, opts ...ResourceOption) (*CamRolePolicyAttachment, error)
public CamRolePolicyAttachment(string name, CamRolePolicyAttachmentArgs args, CustomResourceOptions? opts = null)
public CamRolePolicyAttachment(String name, CamRolePolicyAttachmentArgs args)
public CamRolePolicyAttachment(String name, CamRolePolicyAttachmentArgs args, CustomResourceOptions options)
type: tencentcloud:CamRolePolicyAttachment
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 CamRolePolicyAttachmentArgs
- 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 CamRolePolicyAttachmentArgs
- 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 CamRolePolicyAttachmentArgs
- The arguments to resource properties.
- opts ResourceOption
- Bag of options to control resource's behavior.
- name string
- The unique name of the resource.
- args CamRolePolicyAttachmentArgs
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
- name String
- The unique name of the resource.
- args CamRolePolicyAttachmentArgs
- The arguments to resource properties.
- options CustomResourceOptions
- Bag of options to control resource's behavior.
CamRolePolicyAttachment 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 CamRolePolicyAttachment resource accepts the following input properties:
- Policy
Id string - ID of the policy.
- Role
Id string - ID of the attached CAM role.
- Cam
Role stringPolicy Attachment Id - ID of the resource.
- Policy
Id string - ID of the policy.
- Role
Id string - ID of the attached CAM role.
- Cam
Role stringPolicy Attachment Id - ID of the resource.
- policy
Id String - ID of the policy.
- role
Id String - ID of the attached CAM role.
- cam
Role StringPolicy Attachment Id - ID of the resource.
- policy
Id string - ID of the policy.
- role
Id string - ID of the attached CAM role.
- cam
Role stringPolicy Attachment Id - ID of the resource.
- policy_
id str - ID of the policy.
- role_
id str - ID of the attached CAM role.
- cam_
role_ strpolicy_ attachment_ id - ID of the resource.
- policy
Id String - ID of the policy.
- role
Id String - ID of the attached CAM role.
- cam
Role StringPolicy Attachment Id - ID of the resource.
Outputs
All input properties are implicitly available as output properties. Additionally, the CamRolePolicyAttachment resource produces the following output properties:
- Create
Mode double - Mode of Creation of the CAM role policy attachment.
1
means the CAM policy attachment is created by production, and the others indicate syntax strategy ways. - Create
Time string - The create time of the CAM role policy attachment.
- Id string
- The provider-assigned unique ID for this managed resource.
- Policy
Name string - The 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 role policy attachment.
1
means the CAM policy attachment is created by production, and the others indicate syntax strategy ways. - Create
Time string - The create time of the CAM role policy attachment.
- Id string
- The provider-assigned unique ID for this managed resource.
- Policy
Name string - The 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 role policy attachment.
1
means the CAM policy attachment is created by production, and the others indicate syntax strategy ways. - create
Time String - The create time of the CAM role policy attachment.
- id String
- The provider-assigned unique ID for this managed resource.
- policy
Name String - The 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 role policy attachment.
1
means the CAM policy attachment is created by production, and the others indicate syntax strategy ways. - create
Time string - The create time of the CAM role policy attachment.
- id string
- The provider-assigned unique ID for this managed resource.
- policy
Name string - The 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 role policy attachment.
1
means the CAM policy attachment is created by production, and the others indicate syntax strategy ways. - create_
time str - The create time of the CAM role policy attachment.
- id str
- The provider-assigned unique ID for this managed resource.
- policy_
name str - The 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 role policy attachment.
1
means the CAM policy attachment is created by production, and the others indicate syntax strategy ways. - create
Time String - The create time of the CAM role policy attachment.
- id String
- The provider-assigned unique ID for this managed resource.
- policy
Name String - The name of the policy.
- policy
Type String - Type of the policy strategy.
User
means customer strategy andQCS
means preset strategy.
Look up Existing CamRolePolicyAttachment Resource
Get an existing CamRolePolicyAttachment 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?: CamRolePolicyAttachmentState, opts?: CustomResourceOptions): CamRolePolicyAttachment
@staticmethod
def get(resource_name: str,
id: str,
opts: Optional[ResourceOptions] = None,
cam_role_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,
role_id: Optional[str] = None) -> CamRolePolicyAttachment
func GetCamRolePolicyAttachment(ctx *Context, name string, id IDInput, state *CamRolePolicyAttachmentState, opts ...ResourceOption) (*CamRolePolicyAttachment, error)
public static CamRolePolicyAttachment Get(string name, Input<string> id, CamRolePolicyAttachmentState? state, CustomResourceOptions? opts = null)
public static CamRolePolicyAttachment get(String name, Output<String> id, CamRolePolicyAttachmentState state, CustomResourceOptions options)
resources: _: type: tencentcloud:CamRolePolicyAttachment 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
Role stringPolicy Attachment Id - ID of the resource.
- Create
Mode double - Mode of Creation of the CAM role policy attachment.
1
means the CAM policy attachment is created by production, and the others indicate syntax strategy ways. - Create
Time string - The create time of the CAM role policy attachment.
- Policy
Id string - ID of the policy.
- Policy
Name string - The name of the policy.
- Policy
Type string - Type of the policy strategy.
User
means customer strategy andQCS
means preset strategy. - Role
Id string - ID of the attached CAM role.
- Cam
Role stringPolicy Attachment Id - ID of the resource.
- Create
Mode float64 - Mode of Creation of the CAM role policy attachment.
1
means the CAM policy attachment is created by production, and the others indicate syntax strategy ways. - Create
Time string - The create time of the CAM role policy attachment.
- Policy
Id string - ID of the policy.
- Policy
Name string - The name of the policy.
- Policy
Type string - Type of the policy strategy.
User
means customer strategy andQCS
means preset strategy. - Role
Id string - ID of the attached CAM role.
- cam
Role StringPolicy Attachment Id - ID of the resource.
- create
Mode Double - Mode of Creation of the CAM role policy attachment.
1
means the CAM policy attachment is created by production, and the others indicate syntax strategy ways. - create
Time String - The create time of the CAM role policy attachment.
- policy
Id String - ID of the policy.
- policy
Name String - The name of the policy.
- policy
Type String - Type of the policy strategy.
User
means customer strategy andQCS
means preset strategy. - role
Id String - ID of the attached CAM role.
- cam
Role stringPolicy Attachment Id - ID of the resource.
- create
Mode number - Mode of Creation of the CAM role policy attachment.
1
means the CAM policy attachment is created by production, and the others indicate syntax strategy ways. - create
Time string - The create time of the CAM role policy attachment.
- policy
Id string - ID of the policy.
- policy
Name string - The name of the policy.
- policy
Type string - Type of the policy strategy.
User
means customer strategy andQCS
means preset strategy. - role
Id string - ID of the attached CAM role.
- cam_
role_ strpolicy_ attachment_ id - ID of the resource.
- create_
mode float - Mode of Creation of the CAM role policy attachment.
1
means the CAM policy attachment is created by production, and the others indicate syntax strategy ways. - create_
time str - The create time of the CAM role policy attachment.
- policy_
id str - ID of the policy.
- policy_
name str - The name of the policy.
- policy_
type str - Type of the policy strategy.
User
means customer strategy andQCS
means preset strategy. - role_
id str - ID of the attached CAM role.
- cam
Role StringPolicy Attachment Id - ID of the resource.
- create
Mode Number - Mode of Creation of the CAM role policy attachment.
1
means the CAM policy attachment is created by production, and the others indicate syntax strategy ways. - create
Time String - The create time of the CAM role policy attachment.
- policy
Id String - ID of the policy.
- policy
Name String - The name of the policy.
- policy
Type String - Type of the policy strategy.
User
means customer strategy andQCS
means preset strategy. - role
Id String - ID of the attached CAM role.
Import
CAM role policy attachment can be imported using the id, e.g.
$ pulumi import tencentcloud:index/camRolePolicyAttachment:CamRolePolicyAttachment foo 4611686018427922725#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.