1. Packages
  2. AWS
  3. API Docs
  4. kms
  5. Alias
AWS v6.54.0 published on Friday, Sep 27, 2024 by Pulumi

aws.kms.Alias

Explore with Pulumi AI

aws logo
AWS v6.54.0 published on Friday, Sep 27, 2024 by Pulumi

    Provides an alias for a KMS customer master key. AWS Console enforces 1-to-1 mapping between aliases & keys, but API (hence this provider too) allows you to create as many aliases as the account limits allow you.

    Example Usage

    import * as pulumi from "@pulumi/pulumi";
    import * as aws from "@pulumi/aws";
    
    const a = new aws.kms.Key("a", {});
    const aAlias = new aws.kms.Alias("a", {
        name: "alias/my-key-alias",
        targetKeyId: a.keyId,
    });
    
    import pulumi
    import pulumi_aws as aws
    
    a = aws.kms.Key("a")
    a_alias = aws.kms.Alias("a",
        name="alias/my-key-alias",
        target_key_id=a.key_id)
    
    package main
    
    import (
    	"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/kms"
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    )
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		a, err := kms.NewKey(ctx, "a", nil)
    		if err != nil {
    			return err
    		}
    		_, err = kms.NewAlias(ctx, "a", &kms.AliasArgs{
    			Name:        pulumi.String("alias/my-key-alias"),
    			TargetKeyId: a.KeyId,
    		})
    		if err != nil {
    			return err
    		}
    		return nil
    	})
    }
    
    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using Aws = Pulumi.Aws;
    
    return await Deployment.RunAsync(() => 
    {
        var a = new Aws.Kms.Key("a");
    
        var aAlias = new Aws.Kms.Alias("a", new()
        {
            Name = "alias/my-key-alias",
            TargetKeyId = a.KeyId,
        });
    
    });
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.aws.kms.Key;
    import com.pulumi.aws.kms.Alias;
    import com.pulumi.aws.kms.AliasArgs;
    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 a = new Key("a");
    
            var aAlias = new Alias("aAlias", AliasArgs.builder()
                .name("alias/my-key-alias")
                .targetKeyId(a.keyId())
                .build());
    
        }
    }
    
    resources:
      a:
        type: aws:kms:Key
      aAlias:
        type: aws:kms:Alias
        name: a
        properties:
          name: alias/my-key-alias
          targetKeyId: ${a.keyId}
    

    Create Alias Resource

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

    Constructor syntax

    new Alias(name: string, args: AliasArgs, opts?: CustomResourceOptions);
    @overload
    def Alias(resource_name: str,
              args: AliasArgs,
              opts: Optional[ResourceOptions] = None)
    
    @overload
    def Alias(resource_name: str,
              opts: Optional[ResourceOptions] = None,
              target_key_id: Optional[str] = None,
              name: Optional[str] = None,
              name_prefix: Optional[str] = None)
    func NewAlias(ctx *Context, name string, args AliasArgs, opts ...ResourceOption) (*Alias, error)
    public Alias(string name, AliasArgs args, CustomResourceOptions? opts = null)
    public Alias(String name, AliasArgs args)
    public Alias(String name, AliasArgs args, CustomResourceOptions options)
    
    type: aws:kms:Alias
    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 AliasArgs
    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 AliasArgs
    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 AliasArgs
    The arguments to resource properties.
    opts ResourceOption
    Bag of options to control resource's behavior.
    name string
    The unique name of the resource.
    args AliasArgs
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    name String
    The unique name of the resource.
    args AliasArgs
    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 awsAliasResource = new Aws.Kms.Alias("awsAliasResource", new()
    {
        TargetKeyId = "string",
        Name = "string",
        NamePrefix = "string",
    });
    
    example, err := kms.NewAlias(ctx, "awsAliasResource", &kms.AliasArgs{
    	TargetKeyId: pulumi.String("string"),
    	Name:        pulumi.String("string"),
    	NamePrefix:  pulumi.String("string"),
    })
    
    var awsAliasResource = new Alias("awsAliasResource", AliasArgs.builder()
        .targetKeyId("string")
        .name("string")
        .namePrefix("string")
        .build());
    
    aws_alias_resource = aws.kms.Alias("awsAliasResource",
        target_key_id="string",
        name="string",
        name_prefix="string")
    
    const awsAliasResource = new aws.kms.Alias("awsAliasResource", {
        targetKeyId: "string",
        name: "string",
        namePrefix: "string",
    });
    
    type: aws:kms:Alias
    properties:
        name: string
        namePrefix: string
        targetKeyId: string
    

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

    TargetKeyId string
    Identifier for the key for which the alias is for, can be either an ARN or key_id.
    Name string
    The display name of the alias. The name must start with the word "alias" followed by a forward slash (alias/)
    NamePrefix string
    Creates an unique alias beginning with the specified prefix. The name must start with the word "alias" followed by a forward slash (alias/). Conflicts with name.
    TargetKeyId string
    Identifier for the key for which the alias is for, can be either an ARN or key_id.
    Name string
    The display name of the alias. The name must start with the word "alias" followed by a forward slash (alias/)
    NamePrefix string
    Creates an unique alias beginning with the specified prefix. The name must start with the word "alias" followed by a forward slash (alias/). Conflicts with name.
    targetKeyId String
    Identifier for the key for which the alias is for, can be either an ARN or key_id.
    name String
    The display name of the alias. The name must start with the word "alias" followed by a forward slash (alias/)
    namePrefix String
    Creates an unique alias beginning with the specified prefix. The name must start with the word "alias" followed by a forward slash (alias/). Conflicts with name.
    targetKeyId string
    Identifier for the key for which the alias is for, can be either an ARN or key_id.
    name string
    The display name of the alias. The name must start with the word "alias" followed by a forward slash (alias/)
    namePrefix string
    Creates an unique alias beginning with the specified prefix. The name must start with the word "alias" followed by a forward slash (alias/). Conflicts with name.
    target_key_id str
    Identifier for the key for which the alias is for, can be either an ARN or key_id.
    name str
    The display name of the alias. The name must start with the word "alias" followed by a forward slash (alias/)
    name_prefix str
    Creates an unique alias beginning with the specified prefix. The name must start with the word "alias" followed by a forward slash (alias/). Conflicts with name.
    targetKeyId String
    Identifier for the key for which the alias is for, can be either an ARN or key_id.
    name String
    The display name of the alias. The name must start with the word "alias" followed by a forward slash (alias/)
    namePrefix String
    Creates an unique alias beginning with the specified prefix. The name must start with the word "alias" followed by a forward slash (alias/). Conflicts with name.

    Outputs

    All input properties are implicitly available as output properties. Additionally, the Alias resource produces the following output properties:

    Arn string
    The Amazon Resource Name (ARN) of the key alias.
    Id string
    The provider-assigned unique ID for this managed resource.
    TargetKeyArn string
    The Amazon Resource Name (ARN) of the target key identifier.
    Arn string
    The Amazon Resource Name (ARN) of the key alias.
    Id string
    The provider-assigned unique ID for this managed resource.
    TargetKeyArn string
    The Amazon Resource Name (ARN) of the target key identifier.
    arn String
    The Amazon Resource Name (ARN) of the key alias.
    id String
    The provider-assigned unique ID for this managed resource.
    targetKeyArn String
    The Amazon Resource Name (ARN) of the target key identifier.
    arn string
    The Amazon Resource Name (ARN) of the key alias.
    id string
    The provider-assigned unique ID for this managed resource.
    targetKeyArn string
    The Amazon Resource Name (ARN) of the target key identifier.
    arn str
    The Amazon Resource Name (ARN) of the key alias.
    id str
    The provider-assigned unique ID for this managed resource.
    target_key_arn str
    The Amazon Resource Name (ARN) of the target key identifier.
    arn String
    The Amazon Resource Name (ARN) of the key alias.
    id String
    The provider-assigned unique ID for this managed resource.
    targetKeyArn String
    The Amazon Resource Name (ARN) of the target key identifier.

    Look up Existing Alias Resource

    Get an existing Alias 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?: AliasState, opts?: CustomResourceOptions): Alias
    @staticmethod
    def get(resource_name: str,
            id: str,
            opts: Optional[ResourceOptions] = None,
            arn: Optional[str] = None,
            name: Optional[str] = None,
            name_prefix: Optional[str] = None,
            target_key_arn: Optional[str] = None,
            target_key_id: Optional[str] = None) -> Alias
    func GetAlias(ctx *Context, name string, id IDInput, state *AliasState, opts ...ResourceOption) (*Alias, error)
    public static Alias Get(string name, Input<string> id, AliasState? state, CustomResourceOptions? opts = null)
    public static Alias get(String name, Output<String> id, AliasState 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:
    Arn string
    The Amazon Resource Name (ARN) of the key alias.
    Name string
    The display name of the alias. The name must start with the word "alias" followed by a forward slash (alias/)
    NamePrefix string
    Creates an unique alias beginning with the specified prefix. The name must start with the word "alias" followed by a forward slash (alias/). Conflicts with name.
    TargetKeyArn string
    The Amazon Resource Name (ARN) of the target key identifier.
    TargetKeyId string
    Identifier for the key for which the alias is for, can be either an ARN or key_id.
    Arn string
    The Amazon Resource Name (ARN) of the key alias.
    Name string
    The display name of the alias. The name must start with the word "alias" followed by a forward slash (alias/)
    NamePrefix string
    Creates an unique alias beginning with the specified prefix. The name must start with the word "alias" followed by a forward slash (alias/). Conflicts with name.
    TargetKeyArn string
    The Amazon Resource Name (ARN) of the target key identifier.
    TargetKeyId string
    Identifier for the key for which the alias is for, can be either an ARN or key_id.
    arn String
    The Amazon Resource Name (ARN) of the key alias.
    name String
    The display name of the alias. The name must start with the word "alias" followed by a forward slash (alias/)
    namePrefix String
    Creates an unique alias beginning with the specified prefix. The name must start with the word "alias" followed by a forward slash (alias/). Conflicts with name.
    targetKeyArn String
    The Amazon Resource Name (ARN) of the target key identifier.
    targetKeyId String
    Identifier for the key for which the alias is for, can be either an ARN or key_id.
    arn string
    The Amazon Resource Name (ARN) of the key alias.
    name string
    The display name of the alias. The name must start with the word "alias" followed by a forward slash (alias/)
    namePrefix string
    Creates an unique alias beginning with the specified prefix. The name must start with the word "alias" followed by a forward slash (alias/). Conflicts with name.
    targetKeyArn string
    The Amazon Resource Name (ARN) of the target key identifier.
    targetKeyId string
    Identifier for the key for which the alias is for, can be either an ARN or key_id.
    arn str
    The Amazon Resource Name (ARN) of the key alias.
    name str
    The display name of the alias. The name must start with the word "alias" followed by a forward slash (alias/)
    name_prefix str
    Creates an unique alias beginning with the specified prefix. The name must start with the word "alias" followed by a forward slash (alias/). Conflicts with name.
    target_key_arn str
    The Amazon Resource Name (ARN) of the target key identifier.
    target_key_id str
    Identifier for the key for which the alias is for, can be either an ARN or key_id.
    arn String
    The Amazon Resource Name (ARN) of the key alias.
    name String
    The display name of the alias. The name must start with the word "alias" followed by a forward slash (alias/)
    namePrefix String
    Creates an unique alias beginning with the specified prefix. The name must start with the word "alias" followed by a forward slash (alias/). Conflicts with name.
    targetKeyArn String
    The Amazon Resource Name (ARN) of the target key identifier.
    targetKeyId String
    Identifier for the key for which the alias is for, can be either an ARN or key_id.

    Import

    Using pulumi import, import KMS aliases using the name. For example:

    $ pulumi import aws:kms/alias:Alias a alias/my-key-alias
    

    To learn more about importing existing cloud resources, see Importing resources.

    Package Details

    Repository
    AWS Classic pulumi/pulumi-aws
    License
    Apache-2.0
    Notes
    This Pulumi package is based on the aws Terraform Provider.
    aws logo
    AWS v6.54.0 published on Friday, Sep 27, 2024 by Pulumi