1. Packages
  2. Volcengine
  3. API Docs
  4. ecs
  5. KeyPairAssociate
Volcengine v0.0.24 published on Tuesday, Jun 25, 2024 by Volcengine

volcengine.ecs.KeyPairAssociate

Explore with Pulumi AI

volcengine logo
Volcengine v0.0.24 published on Tuesday, Jun 25, 2024 by Volcengine

    Provides a resource to manage ecs key pair associate

    Example Usage

    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using Volcengine = Pulumi.Volcengine;
    
    return await Deployment.RunAsync(() => 
    {
        var fooKeyPair = new Volcengine.Ecs.KeyPair("fooKeyPair", new()
        {
            KeyPairName = "acc-test-key-name",
            Description = "acc-test",
        });
    
        var fooZones = Volcengine.Ecs.Zones.Invoke();
    
        var fooImages = Volcengine.Ecs.Images.Invoke(new()
        {
            OsType = "Linux",
            Visibility = "public",
            InstanceTypeId = "ecs.g1.large",
        });
    
        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()
        {
            VpcId = fooVpc.Id,
            SecurityGroupName = "acc-test-security-group",
        });
    
        var fooInstance = new Volcengine.Ecs.Instance("fooInstance", new()
        {
            ImageId = fooImages.Apply(imagesResult => imagesResult.Images[0]?.ImageId),
            InstanceType = "ecs.g1.large",
            InstanceName = "acc-test-ecs-name",
            Password = "your password",
            InstanceChargeType = "PostPaid",
            SystemVolumeType = "ESSD_PL0",
            SystemVolumeSize = 40,
            SubnetId = fooSubnet.Id,
            SecurityGroupIds = new[]
            {
                fooSecurityGroup.Id,
            },
        });
    
        var fooKeyPairAssociate = new Volcengine.Ecs.KeyPairAssociate("fooKeyPairAssociate", new()
        {
            InstanceId = fooInstance.Id,
            KeyPairId = fooKeyPair.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/vpc"
    )
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		fooKeyPair, err := ecs.NewKeyPair(ctx, "fooKeyPair", &ecs.KeyPairArgs{
    			KeyPairName: pulumi.String("acc-test-key-name"),
    			Description: pulumi.String("acc-test"),
    		})
    		if err != nil {
    			return err
    		}
    		fooZones, err := ecs.Zones(ctx, nil, nil)
    		if err != nil {
    			return err
    		}
    		fooImages, err := ecs.Images(ctx, &ecs.ImagesArgs{
    			OsType:         pulumi.StringRef("Linux"),
    			Visibility:     pulumi.StringRef("public"),
    			InstanceTypeId: pulumi.StringRef("ecs.g1.large"),
    		}, 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{
    			VpcId:             fooVpc.ID(),
    			SecurityGroupName: pulumi.String("acc-test-security-group"),
    		})
    		if err != nil {
    			return err
    		}
    		fooInstance, err := ecs.NewInstance(ctx, "fooInstance", &ecs.InstanceArgs{
    			ImageId:            *pulumi.String(fooImages.Images[0].ImageId),
    			InstanceType:       pulumi.String("ecs.g1.large"),
    			InstanceName:       pulumi.String("acc-test-ecs-name"),
    			Password:           pulumi.String("your password"),
    			InstanceChargeType: pulumi.String("PostPaid"),
    			SystemVolumeType:   pulumi.String("ESSD_PL0"),
    			SystemVolumeSize:   pulumi.Int(40),
    			SubnetId:           fooSubnet.ID(),
    			SecurityGroupIds: pulumi.StringArray{
    				fooSecurityGroup.ID(),
    			},
    		})
    		if err != nil {
    			return err
    		}
    		_, err = ecs.NewKeyPairAssociate(ctx, "fooKeyPairAssociate", &ecs.KeyPairAssociateArgs{
    			InstanceId: fooInstance.ID(),
    			KeyPairId:  fooKeyPair.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.KeyPair;
    import com.pulumi.volcengine.ecs.KeyPairArgs;
    import com.pulumi.volcengine.ecs.EcsFunctions;
    import com.pulumi.volcengine.ecs.inputs.ZonesArgs;
    import com.pulumi.volcengine.ecs.inputs.ImagesArgs;
    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.Instance;
    import com.pulumi.volcengine.ecs.InstanceArgs;
    import com.pulumi.volcengine.ecs.KeyPairAssociate;
    import com.pulumi.volcengine.ecs.KeyPairAssociateArgs;
    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) {
            var fooKeyPair = new KeyPair("fooKeyPair", KeyPairArgs.builder()        
                .keyPairName("acc-test-key-name")
                .description("acc-test")
                .build());
    
            final var fooZones = EcsFunctions.Zones();
    
            final var fooImages = EcsFunctions.Images(ImagesArgs.builder()
                .osType("Linux")
                .visibility("public")
                .instanceTypeId("ecs.g1.large")
                .build());
    
            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()        
                .vpcId(fooVpc.id())
                .securityGroupName("acc-test-security-group")
                .build());
    
            var fooInstance = new Instance("fooInstance", InstanceArgs.builder()        
                .imageId(fooImages.applyValue(imagesResult -> imagesResult.images()[0].imageId()))
                .instanceType("ecs.g1.large")
                .instanceName("acc-test-ecs-name")
                .password("your password")
                .instanceChargeType("PostPaid")
                .systemVolumeType("ESSD_PL0")
                .systemVolumeSize(40)
                .subnetId(fooSubnet.id())
                .securityGroupIds(fooSecurityGroup.id())
                .build());
    
            var fooKeyPairAssociate = new KeyPairAssociate("fooKeyPairAssociate", KeyPairAssociateArgs.builder()        
                .instanceId(fooInstance.id())
                .keyPairId(fooKeyPair.id())
                .build());
    
        }
    }
    
    import pulumi
    import pulumi_volcengine as volcengine
    
    foo_key_pair = volcengine.ecs.KeyPair("fooKeyPair",
        key_pair_name="acc-test-key-name",
        description="acc-test")
    foo_zones = volcengine.ecs.zones()
    foo_images = volcengine.ecs.images(os_type="Linux",
        visibility="public",
        instance_type_id="ecs.g1.large")
    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",
        vpc_id=foo_vpc.id,
        security_group_name="acc-test-security-group")
    foo_instance = volcengine.ecs.Instance("fooInstance",
        image_id=foo_images.images[0].image_id,
        instance_type="ecs.g1.large",
        instance_name="acc-test-ecs-name",
        password="your password",
        instance_charge_type="PostPaid",
        system_volume_type="ESSD_PL0",
        system_volume_size=40,
        subnet_id=foo_subnet.id,
        security_group_ids=[foo_security_group.id])
    foo_key_pair_associate = volcengine.ecs.KeyPairAssociate("fooKeyPairAssociate",
        instance_id=foo_instance.id,
        key_pair_id=foo_key_pair.id)
    
    import * as pulumi from "@pulumi/pulumi";
    import * as volcengine from "@pulumi/volcengine";
    import * as volcengine from "@volcengine/pulumi";
    
    const fooKeyPair = new volcengine.ecs.KeyPair("fooKeyPair", {
        keyPairName: "acc-test-key-name",
        description: "acc-test",
    });
    const fooZones = volcengine.ecs.Zones({});
    const fooImages = volcengine.ecs.Images({
        osType: "Linux",
        visibility: "public",
        instanceTypeId: "ecs.g1.large",
    });
    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", {
        vpcId: fooVpc.id,
        securityGroupName: "acc-test-security-group",
    });
    const fooInstance = new volcengine.ecs.Instance("fooInstance", {
        imageId: fooImages.then(fooImages => fooImages.images?.[0]?.imageId),
        instanceType: "ecs.g1.large",
        instanceName: "acc-test-ecs-name",
        password: "your password",
        instanceChargeType: "PostPaid",
        systemVolumeType: "ESSD_PL0",
        systemVolumeSize: 40,
        subnetId: fooSubnet.id,
        securityGroupIds: [fooSecurityGroup.id],
    });
    const fooKeyPairAssociate = new volcengine.ecs.KeyPairAssociate("fooKeyPairAssociate", {
        instanceId: fooInstance.id,
        keyPairId: fooKeyPair.id,
    });
    
    resources:
      fooKeyPair:
        type: volcengine:ecs:KeyPair
        properties:
          keyPairName: acc-test-key-name
          description: acc-test
      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:
          vpcId: ${fooVpc.id}
          securityGroupName: acc-test-security-group
      fooInstance:
        type: volcengine:ecs:Instance
        properties:
          imageId: ${fooImages.images[0].imageId}
          instanceType: ecs.g1.large
          instanceName: acc-test-ecs-name
          password: your password
          instanceChargeType: PostPaid
          systemVolumeType: ESSD_PL0
          systemVolumeSize: 40
          subnetId: ${fooSubnet.id}
          securityGroupIds:
            - ${fooSecurityGroup.id}
      fooKeyPairAssociate:
        type: volcengine:ecs:KeyPairAssociate
        properties:
          instanceId: ${fooInstance.id}
          keyPairId: ${fooKeyPair.id}
    variables:
      fooZones:
        fn::invoke:
          Function: volcengine:ecs:Zones
          Arguments: {}
      fooImages:
        fn::invoke:
          Function: volcengine:ecs:Images
          Arguments:
            osType: Linux
            visibility: public
            instanceTypeId: ecs.g1.large
    

    Create KeyPairAssociate Resource

    Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.

    Constructor syntax

    new KeyPairAssociate(name: string, args: KeyPairAssociateArgs, opts?: CustomResourceOptions);
    @overload
    def KeyPairAssociate(resource_name: str,
                         args: KeyPairAssociateArgs,
                         opts: Optional[ResourceOptions] = None)
    
    @overload
    def KeyPairAssociate(resource_name: str,
                         opts: Optional[ResourceOptions] = None,
                         instance_id: Optional[str] = None,
                         key_pair_id: Optional[str] = None)
    func NewKeyPairAssociate(ctx *Context, name string, args KeyPairAssociateArgs, opts ...ResourceOption) (*KeyPairAssociate, error)
    public KeyPairAssociate(string name, KeyPairAssociateArgs args, CustomResourceOptions? opts = null)
    public KeyPairAssociate(String name, KeyPairAssociateArgs args)
    public KeyPairAssociate(String name, KeyPairAssociateArgs args, CustomResourceOptions options)
    
    type: volcengine:ecs:KeyPairAssociate
    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 KeyPairAssociateArgs
    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 KeyPairAssociateArgs
    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 KeyPairAssociateArgs
    The arguments to resource properties.
    opts ResourceOption
    Bag of options to control resource's behavior.
    name string
    The unique name of the resource.
    args KeyPairAssociateArgs
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    name String
    The unique name of the resource.
    args KeyPairAssociateArgs
    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 keyPairAssociateResource = new Volcengine.Ecs.KeyPairAssociate("keyPairAssociateResource", new()
    {
        InstanceId = "string",
        KeyPairId = "string",
    });
    
    example, err := ecs.NewKeyPairAssociate(ctx, "keyPairAssociateResource", &ecs.KeyPairAssociateArgs{
    	InstanceId: pulumi.String("string"),
    	KeyPairId:  pulumi.String("string"),
    })
    
    var keyPairAssociateResource = new KeyPairAssociate("keyPairAssociateResource", KeyPairAssociateArgs.builder()
        .instanceId("string")
        .keyPairId("string")
        .build());
    
    key_pair_associate_resource = volcengine.ecs.KeyPairAssociate("keyPairAssociateResource",
        instance_id="string",
        key_pair_id="string")
    
    const keyPairAssociateResource = new volcengine.ecs.KeyPairAssociate("keyPairAssociateResource", {
        instanceId: "string",
        keyPairId: "string",
    });
    
    type: volcengine:ecs:KeyPairAssociate
    properties:
        instanceId: string
        keyPairId: string
    

    KeyPairAssociate 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 KeyPairAssociate resource accepts the following input properties:

    InstanceId string
    The ID of ECS Instance.
    KeyPairId string
    The ID of ECS KeyPair Associate.
    InstanceId string
    The ID of ECS Instance.
    KeyPairId string
    The ID of ECS KeyPair Associate.
    instanceId String
    The ID of ECS Instance.
    keyPairId String
    The ID of ECS KeyPair Associate.
    instanceId string
    The ID of ECS Instance.
    keyPairId string
    The ID of ECS KeyPair Associate.
    instance_id str
    The ID of ECS Instance.
    key_pair_id str
    The ID of ECS KeyPair Associate.
    instanceId String
    The ID of ECS Instance.
    keyPairId String
    The ID of ECS KeyPair Associate.

    Outputs

    All input properties are implicitly available as output properties. Additionally, the KeyPairAssociate 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 KeyPairAssociate Resource

    Get an existing KeyPairAssociate 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?: KeyPairAssociateState, opts?: CustomResourceOptions): KeyPairAssociate
    @staticmethod
    def get(resource_name: str,
            id: str,
            opts: Optional[ResourceOptions] = None,
            instance_id: Optional[str] = None,
            key_pair_id: Optional[str] = None) -> KeyPairAssociate
    func GetKeyPairAssociate(ctx *Context, name string, id IDInput, state *KeyPairAssociateState, opts ...ResourceOption) (*KeyPairAssociate, error)
    public static KeyPairAssociate Get(string name, Input<string> id, KeyPairAssociateState? state, CustomResourceOptions? opts = null)
    public static KeyPairAssociate get(String name, Output<String> id, KeyPairAssociateState 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.
    The following state arguments are supported:
    InstanceId string
    The ID of ECS Instance.
    KeyPairId string
    The ID of ECS KeyPair Associate.
    InstanceId string
    The ID of ECS Instance.
    KeyPairId string
    The ID of ECS KeyPair Associate.
    instanceId String
    The ID of ECS Instance.
    keyPairId String
    The ID of ECS KeyPair Associate.
    instanceId string
    The ID of ECS Instance.
    keyPairId string
    The ID of ECS KeyPair Associate.
    instance_id str
    The ID of ECS Instance.
    key_pair_id str
    The ID of ECS KeyPair Associate.
    instanceId String
    The ID of ECS Instance.
    keyPairId String
    The ID of ECS KeyPair Associate.

    Import

    ECS key pair associate can be imported using the id, e.g. After binding the key pair, the instance needs to be restarted for the key pair to take effect. After the key pair is bound, the password login method will automatically become invalid. If your instance has been set for password login, after the key pair is bound, you will no longer be able to use the password login method.

     $ pulumi import volcengine:ecs/keyPairAssociate:KeyPairAssociate default kp-ybti5tkpkv2udbfolrft:i-mizl7m1kqccg5smt1bdpijuj
    

    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.
    volcengine logo
    Volcengine v0.0.24 published on Tuesday, Jun 25, 2024 by Volcengine