volcengine.ecs.IamRoleAttachment
Explore with Pulumi AI
Provides a resource to manage iam role attachment
Example Usage
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Volcengine = Pulumi.Volcengine;
return await Deployment.RunAsync(() =>
{
var fooZones = Volcengine.Ecs.Zones.Invoke();
var fooVpc = new Volcengine.Vpc.Vpc("fooVpc", new()
{
VpcName = "acc-test-vpc",
CidrBlock = "172.16.0.0/16",
});
var fooSubnet = new Volcengine.Vpc.Subnet("fooSubnet", new()
{
SubnetName = "acc-test-subnet",
CidrBlock = "172.16.0.0/24",
ZoneId = fooZones.Apply(zonesResult => zonesResult.Zones[0]?.Id),
VpcId = fooVpc.Id,
});
var fooSecurityGroup = new Volcengine.Vpc.SecurityGroup("fooSecurityGroup", new()
{
SecurityGroupName = "acc-test-security-group",
VpcId = fooVpc.Id,
});
var fooImages = Volcengine.Ecs.Images.Invoke(new()
{
OsType = "Linux",
Visibility = "public",
InstanceTypeId = "ecs.g1ie.large",
});
var fooInstance = new Volcengine.Ecs.Instance("fooInstance", new()
{
InstanceName = "acc-test-ecs",
Description = "acc-test",
HostName = "tf-acc-test",
ImageId = fooImages.Apply(imagesResult => imagesResult.Images[0]?.ImageId),
InstanceType = "ecs.g1ie.large",
Password = "93f0cb0614Aab12",
InstanceChargeType = "PostPaid",
SystemVolumeType = "ESSD_PL0",
SystemVolumeSize = 40,
DataVolumes = new[]
{
new Volcengine.Ecs.Inputs.InstanceDataVolumeArgs
{
VolumeType = "ESSD_PL0",
Size = 50,
DeleteWithInstance = true,
},
},
SubnetId = fooSubnet.Id,
SecurityGroupIds = new[]
{
fooSecurityGroup.Id,
},
ProjectName = "default",
Tags = new[]
{
new Volcengine.Ecs.Inputs.InstanceTagArgs
{
Key = "k1",
Value = "v1",
},
},
});
var fooRole = new Volcengine.Iam.Role("fooRole", new()
{
RoleName = "acc-test-role",
DisplayName = "acc-test",
Description = "acc-test",
TrustPolicyDocument = "{\"Statement\":[{\"Effect\":\"Allow\",\"Action\":[\"sts:AssumeRole\"],\"Principal\":{\"Service\":[\"ecs\"]}}]}",
MaxSessionDuration = 36000,
});
var fooIamRoleAttachment = new Volcengine.Ecs.IamRoleAttachment("fooIamRoleAttachment", new()
{
IamRoleName = fooRole.Id,
InstanceId = fooInstance.Id,
});
});
package main
import (
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
"github.com/volcengine/pulumi-volcengine/sdk/go/volcengine/ecs"
"github.com/volcengine/pulumi-volcengine/sdk/go/volcengine/iam"
"github.com/volcengine/pulumi-volcengine/sdk/go/volcengine/vpc"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
fooZones, err := ecs.Zones(ctx, nil, nil)
if err != nil {
return err
}
fooVpc, err := vpc.NewVpc(ctx, "fooVpc", &vpc.VpcArgs{
VpcName: pulumi.String("acc-test-vpc"),
CidrBlock: pulumi.String("172.16.0.0/16"),
})
if err != nil {
return err
}
fooSubnet, err := vpc.NewSubnet(ctx, "fooSubnet", &vpc.SubnetArgs{
SubnetName: pulumi.String("acc-test-subnet"),
CidrBlock: pulumi.String("172.16.0.0/24"),
ZoneId: *pulumi.String(fooZones.Zones[0].Id),
VpcId: fooVpc.ID(),
})
if err != nil {
return err
}
fooSecurityGroup, err := vpc.NewSecurityGroup(ctx, "fooSecurityGroup", &vpc.SecurityGroupArgs{
SecurityGroupName: pulumi.String("acc-test-security-group"),
VpcId: fooVpc.ID(),
})
if err != nil {
return err
}
fooImages, err := ecs.Images(ctx, &ecs.ImagesArgs{
OsType: pulumi.StringRef("Linux"),
Visibility: pulumi.StringRef("public"),
InstanceTypeId: pulumi.StringRef("ecs.g1ie.large"),
}, nil)
if err != nil {
return err
}
fooInstance, err := ecs.NewInstance(ctx, "fooInstance", &ecs.InstanceArgs{
InstanceName: pulumi.String("acc-test-ecs"),
Description: pulumi.String("acc-test"),
HostName: pulumi.String("tf-acc-test"),
ImageId: *pulumi.String(fooImages.Images[0].ImageId),
InstanceType: pulumi.String("ecs.g1ie.large"),
Password: pulumi.String("93f0cb0614Aab12"),
InstanceChargeType: pulumi.String("PostPaid"),
SystemVolumeType: pulumi.String("ESSD_PL0"),
SystemVolumeSize: pulumi.Int(40),
DataVolumes: ecs.InstanceDataVolumeArray{
&ecs.InstanceDataVolumeArgs{
VolumeType: pulumi.String("ESSD_PL0"),
Size: pulumi.Int(50),
DeleteWithInstance: pulumi.Bool(true),
},
},
SubnetId: fooSubnet.ID(),
SecurityGroupIds: pulumi.StringArray{
fooSecurityGroup.ID(),
},
ProjectName: pulumi.String("default"),
Tags: ecs.InstanceTagArray{
&ecs.InstanceTagArgs{
Key: pulumi.String("k1"),
Value: pulumi.String("v1"),
},
},
})
if err != nil {
return err
}
fooRole, err := iam.NewRole(ctx, "fooRole", &iam.RoleArgs{
RoleName: pulumi.String("acc-test-role"),
DisplayName: pulumi.String("acc-test"),
Description: pulumi.String("acc-test"),
TrustPolicyDocument: pulumi.String("{\"Statement\":[{\"Effect\":\"Allow\",\"Action\":[\"sts:AssumeRole\"],\"Principal\":{\"Service\":[\"ecs\"]}}]}"),
MaxSessionDuration: pulumi.Int(36000),
})
if err != nil {
return err
}
_, err = ecs.NewIamRoleAttachment(ctx, "fooIamRoleAttachment", &ecs.IamRoleAttachmentArgs{
IamRoleName: fooRole.ID(),
InstanceId: fooInstance.ID(),
})
if err != nil {
return err
}
return nil
})
}
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.volcengine.ecs.EcsFunctions;
import com.pulumi.volcengine.ecs.inputs.ZonesArgs;
import com.pulumi.volcengine.vpc.Vpc;
import com.pulumi.volcengine.vpc.VpcArgs;
import com.pulumi.volcengine.vpc.Subnet;
import com.pulumi.volcengine.vpc.SubnetArgs;
import com.pulumi.volcengine.vpc.SecurityGroup;
import com.pulumi.volcengine.vpc.SecurityGroupArgs;
import com.pulumi.volcengine.ecs.inputs.ImagesArgs;
import com.pulumi.volcengine.ecs.Instance;
import com.pulumi.volcengine.ecs.InstanceArgs;
import com.pulumi.volcengine.ecs.inputs.InstanceDataVolumeArgs;
import com.pulumi.volcengine.ecs.inputs.InstanceTagArgs;
import com.pulumi.volcengine.iam.Role;
import com.pulumi.volcengine.iam.RoleArgs;
import com.pulumi.volcengine.ecs.IamRoleAttachment;
import com.pulumi.volcengine.ecs.IamRoleAttachmentArgs;
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 fooZones = EcsFunctions.Zones();
var fooVpc = new Vpc("fooVpc", VpcArgs.builder()
.vpcName("acc-test-vpc")
.cidrBlock("172.16.0.0/16")
.build());
var fooSubnet = new Subnet("fooSubnet", SubnetArgs.builder()
.subnetName("acc-test-subnet")
.cidrBlock("172.16.0.0/24")
.zoneId(fooZones.applyValue(zonesResult -> zonesResult.zones()[0].id()))
.vpcId(fooVpc.id())
.build());
var fooSecurityGroup = new SecurityGroup("fooSecurityGroup", SecurityGroupArgs.builder()
.securityGroupName("acc-test-security-group")
.vpcId(fooVpc.id())
.build());
final var fooImages = EcsFunctions.Images(ImagesArgs.builder()
.osType("Linux")
.visibility("public")
.instanceTypeId("ecs.g1ie.large")
.build());
var fooInstance = new Instance("fooInstance", InstanceArgs.builder()
.instanceName("acc-test-ecs")
.description("acc-test")
.hostName("tf-acc-test")
.imageId(fooImages.applyValue(imagesResult -> imagesResult.images()[0].imageId()))
.instanceType("ecs.g1ie.large")
.password("93f0cb0614Aab12")
.instanceChargeType("PostPaid")
.systemVolumeType("ESSD_PL0")
.systemVolumeSize(40)
.dataVolumes(InstanceDataVolumeArgs.builder()
.volumeType("ESSD_PL0")
.size(50)
.deleteWithInstance(true)
.build())
.subnetId(fooSubnet.id())
.securityGroupIds(fooSecurityGroup.id())
.projectName("default")
.tags(InstanceTagArgs.builder()
.key("k1")
.value("v1")
.build())
.build());
var fooRole = new Role("fooRole", RoleArgs.builder()
.roleName("acc-test-role")
.displayName("acc-test")
.description("acc-test")
.trustPolicyDocument("{\"Statement\":[{\"Effect\":\"Allow\",\"Action\":[\"sts:AssumeRole\"],\"Principal\":{\"Service\":[\"ecs\"]}}]}")
.maxSessionDuration(36000)
.build());
var fooIamRoleAttachment = new IamRoleAttachment("fooIamRoleAttachment", IamRoleAttachmentArgs.builder()
.iamRoleName(fooRole.id())
.instanceId(fooInstance.id())
.build());
}
}
import pulumi
import pulumi_volcengine as volcengine
foo_zones = volcengine.ecs.zones()
foo_vpc = volcengine.vpc.Vpc("fooVpc",
vpc_name="acc-test-vpc",
cidr_block="172.16.0.0/16")
foo_subnet = volcengine.vpc.Subnet("fooSubnet",
subnet_name="acc-test-subnet",
cidr_block="172.16.0.0/24",
zone_id=foo_zones.zones[0].id,
vpc_id=foo_vpc.id)
foo_security_group = volcengine.vpc.SecurityGroup("fooSecurityGroup",
security_group_name="acc-test-security-group",
vpc_id=foo_vpc.id)
foo_images = volcengine.ecs.images(os_type="Linux",
visibility="public",
instance_type_id="ecs.g1ie.large")
foo_instance = volcengine.ecs.Instance("fooInstance",
instance_name="acc-test-ecs",
description="acc-test",
host_name="tf-acc-test",
image_id=foo_images.images[0].image_id,
instance_type="ecs.g1ie.large",
password="93f0cb0614Aab12",
instance_charge_type="PostPaid",
system_volume_type="ESSD_PL0",
system_volume_size=40,
data_volumes=[volcengine.ecs.InstanceDataVolumeArgs(
volume_type="ESSD_PL0",
size=50,
delete_with_instance=True,
)],
subnet_id=foo_subnet.id,
security_group_ids=[foo_security_group.id],
project_name="default",
tags=[volcengine.ecs.InstanceTagArgs(
key="k1",
value="v1",
)])
foo_role = volcengine.iam.Role("fooRole",
role_name="acc-test-role",
display_name="acc-test",
description="acc-test",
trust_policy_document="{\"Statement\":[{\"Effect\":\"Allow\",\"Action\":[\"sts:AssumeRole\"],\"Principal\":{\"Service\":[\"ecs\"]}}]}",
max_session_duration=36000)
foo_iam_role_attachment = volcengine.ecs.IamRoleAttachment("fooIamRoleAttachment",
iam_role_name=foo_role.id,
instance_id=foo_instance.id)
import * as pulumi from "@pulumi/pulumi";
import * as volcengine from "@pulumi/volcengine";
import * as volcengine from "@volcengine/pulumi";
const fooZones = volcengine.ecs.Zones({});
const fooVpc = new volcengine.vpc.Vpc("fooVpc", {
vpcName: "acc-test-vpc",
cidrBlock: "172.16.0.0/16",
});
const fooSubnet = new volcengine.vpc.Subnet("fooSubnet", {
subnetName: "acc-test-subnet",
cidrBlock: "172.16.0.0/24",
zoneId: fooZones.then(fooZones => fooZones.zones?.[0]?.id),
vpcId: fooVpc.id,
});
const fooSecurityGroup = new volcengine.vpc.SecurityGroup("fooSecurityGroup", {
securityGroupName: "acc-test-security-group",
vpcId: fooVpc.id,
});
const fooImages = volcengine.ecs.Images({
osType: "Linux",
visibility: "public",
instanceTypeId: "ecs.g1ie.large",
});
const fooInstance = new volcengine.ecs.Instance("fooInstance", {
instanceName: "acc-test-ecs",
description: "acc-test",
hostName: "tf-acc-test",
imageId: fooImages.then(fooImages => fooImages.images?.[0]?.imageId),
instanceType: "ecs.g1ie.large",
password: "93f0cb0614Aab12",
instanceChargeType: "PostPaid",
systemVolumeType: "ESSD_PL0",
systemVolumeSize: 40,
dataVolumes: [{
volumeType: "ESSD_PL0",
size: 50,
deleteWithInstance: true,
}],
subnetId: fooSubnet.id,
securityGroupIds: [fooSecurityGroup.id],
projectName: "default",
tags: [{
key: "k1",
value: "v1",
}],
});
const fooRole = new volcengine.iam.Role("fooRole", {
roleName: "acc-test-role",
displayName: "acc-test",
description: "acc-test",
trustPolicyDocument: "{\"Statement\":[{\"Effect\":\"Allow\",\"Action\":[\"sts:AssumeRole\"],\"Principal\":{\"Service\":[\"ecs\"]}}]}",
maxSessionDuration: 36000,
});
const fooIamRoleAttachment = new volcengine.ecs.IamRoleAttachment("fooIamRoleAttachment", {
iamRoleName: fooRole.id,
instanceId: fooInstance.id,
});
resources:
fooVpc:
type: volcengine:vpc:Vpc
properties:
vpcName: acc-test-vpc
cidrBlock: 172.16.0.0/16
fooSubnet:
type: volcengine:vpc:Subnet
properties:
subnetName: acc-test-subnet
cidrBlock: 172.16.0.0/24
zoneId: ${fooZones.zones[0].id}
vpcId: ${fooVpc.id}
fooSecurityGroup:
type: volcengine:vpc:SecurityGroup
properties:
securityGroupName: acc-test-security-group
vpcId: ${fooVpc.id}
fooInstance:
type: volcengine:ecs:Instance
properties:
instanceName: acc-test-ecs
description: acc-test
hostName: tf-acc-test
imageId: ${fooImages.images[0].imageId}
instanceType: ecs.g1ie.large
password: 93f0cb0614Aab12
instanceChargeType: PostPaid
systemVolumeType: ESSD_PL0
systemVolumeSize: 40
dataVolumes:
- volumeType: ESSD_PL0
size: 50
deleteWithInstance: true
subnetId: ${fooSubnet.id}
securityGroupIds:
- ${fooSecurityGroup.id}
projectName: default
tags:
- key: k1
value: v1
fooRole:
type: volcengine:iam:Role
properties:
roleName: acc-test-role
displayName: acc-test
description: acc-test
trustPolicyDocument: '{"Statement":[{"Effect":"Allow","Action":["sts:AssumeRole"],"Principal":{"Service":["ecs"]}}]}'
maxSessionDuration: 36000
fooIamRoleAttachment:
type: volcengine:ecs:IamRoleAttachment
properties:
iamRoleName: ${fooRole.id}
instanceId: ${fooInstance.id}
variables:
fooZones:
fn::invoke:
Function: volcengine:ecs:Zones
Arguments: {}
fooImages:
fn::invoke:
Function: volcengine:ecs:Images
Arguments:
osType: Linux
visibility: public
instanceTypeId: ecs.g1ie.large
Create IamRoleAttachment Resource
Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.
Constructor syntax
new IamRoleAttachment(name: string, args: IamRoleAttachmentArgs, opts?: CustomResourceOptions);
@overload
def IamRoleAttachment(resource_name: str,
args: IamRoleAttachmentArgs,
opts: Optional[ResourceOptions] = None)
@overload
def IamRoleAttachment(resource_name: str,
opts: Optional[ResourceOptions] = None,
iam_role_name: Optional[str] = None,
instance_id: Optional[str] = None)
func NewIamRoleAttachment(ctx *Context, name string, args IamRoleAttachmentArgs, opts ...ResourceOption) (*IamRoleAttachment, error)
public IamRoleAttachment(string name, IamRoleAttachmentArgs args, CustomResourceOptions? opts = null)
public IamRoleAttachment(String name, IamRoleAttachmentArgs args)
public IamRoleAttachment(String name, IamRoleAttachmentArgs args, CustomResourceOptions options)
type: volcengine:ecs:IamRoleAttachment
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 IamRoleAttachmentArgs
- 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 IamRoleAttachmentArgs
- 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 IamRoleAttachmentArgs
- The arguments to resource properties.
- opts ResourceOption
- Bag of options to control resource's behavior.
- name string
- The unique name of the resource.
- args IamRoleAttachmentArgs
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
- name String
- The unique name of the resource.
- args IamRoleAttachmentArgs
- The arguments to resource properties.
- options CustomResourceOptions
- Bag of options to control resource's behavior.
Constructor example
The following reference example uses placeholder values for all input properties.
var iamRoleAttachmentResource = new Volcengine.Ecs.IamRoleAttachment("iamRoleAttachmentResource", new()
{
IamRoleName = "string",
InstanceId = "string",
});
example, err := ecs.NewIamRoleAttachment(ctx, "iamRoleAttachmentResource", &ecs.IamRoleAttachmentArgs{
IamRoleName: pulumi.String("string"),
InstanceId: pulumi.String("string"),
})
var iamRoleAttachmentResource = new IamRoleAttachment("iamRoleAttachmentResource", IamRoleAttachmentArgs.builder()
.iamRoleName("string")
.instanceId("string")
.build());
iam_role_attachment_resource = volcengine.ecs.IamRoleAttachment("iamRoleAttachmentResource",
iam_role_name="string",
instance_id="string")
const iamRoleAttachmentResource = new volcengine.ecs.IamRoleAttachment("iamRoleAttachmentResource", {
iamRoleName: "string",
instanceId: "string",
});
type: volcengine:ecs:IamRoleAttachment
properties:
iamRoleName: string
instanceId: string
IamRoleAttachment Resource Properties
To learn more about resource properties and how to use them, see Inputs and Outputs in the Architecture and Concepts docs.
Inputs
The IamRoleAttachment resource accepts the following input properties:
- Iam
Role stringName - The name of the iam role.
- Instance
Id string - The id of the ecs instance.
- Iam
Role stringName - The name of the iam role.
- Instance
Id string - The id of the ecs instance.
- iam
Role StringName - The name of the iam role.
- instance
Id String - The id of the ecs instance.
- iam
Role stringName - The name of the iam role.
- instance
Id string - The id of the ecs instance.
- iam_
role_ strname - The name of the iam role.
- instance_
id str - The id of the ecs instance.
- iam
Role StringName - The name of the iam role.
- instance
Id String - The id of the ecs instance.
Outputs
All input properties are implicitly available as output properties. Additionally, the IamRoleAttachment resource produces the following output properties:
- Id string
- The provider-assigned unique ID for this managed resource.
- Id string
- The provider-assigned unique ID for this managed resource.
- id String
- The provider-assigned unique ID for this managed resource.
- id string
- The provider-assigned unique ID for this managed resource.
- id str
- The provider-assigned unique ID for this managed resource.
- id String
- The provider-assigned unique ID for this managed resource.
Look up Existing IamRoleAttachment Resource
Get an existing IamRoleAttachment 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?: IamRoleAttachmentState, opts?: CustomResourceOptions): IamRoleAttachment
@staticmethod
def get(resource_name: str,
id: str,
opts: Optional[ResourceOptions] = None,
iam_role_name: Optional[str] = None,
instance_id: Optional[str] = None) -> IamRoleAttachment
func GetIamRoleAttachment(ctx *Context, name string, id IDInput, state *IamRoleAttachmentState, opts ...ResourceOption) (*IamRoleAttachment, error)
public static IamRoleAttachment Get(string name, Input<string> id, IamRoleAttachmentState? state, CustomResourceOptions? opts = null)
public static IamRoleAttachment get(String name, Output<String> id, IamRoleAttachmentState state, CustomResourceOptions options)
Resource lookup is not supported in YAML
- 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.
- Iam
Role stringName - The name of the iam role.
- Instance
Id string - The id of the ecs instance.
- Iam
Role stringName - The name of the iam role.
- Instance
Id string - The id of the ecs instance.
- iam
Role StringName - The name of the iam role.
- instance
Id String - The id of the ecs instance.
- iam
Role stringName - The name of the iam role.
- instance
Id string - The id of the ecs instance.
- iam_
role_ strname - The name of the iam role.
- instance_
id str - The id of the ecs instance.
- iam
Role StringName - The name of the iam role.
- instance
Id String - The id of the ecs instance.
Import
IamRoleAttachment can be imported using the iam_role_name:instance_id, e.g.
$ pulumi import volcengine:ecs/iamRoleAttachment:IamRoleAttachment default role_name:instance_id
To learn more about importing existing cloud resources, see Importing resources.
Package Details
- Repository
- volcengine volcengine/pulumi-volcengine
- License
- Apache-2.0
- Notes
- This Pulumi package is based on the
volcengine
Terraform Provider.