1. Packages
  2. AWS
  3. API Docs
  4. ec2
  5. AmiLaunchPermission
AWS v6.60.0 published on Tuesday, Nov 19, 2024 by Pulumi

aws.ec2.AmiLaunchPermission

Explore with Pulumi AI

aws logo
AWS v6.60.0 published on Tuesday, Nov 19, 2024 by Pulumi

    Adds a launch permission to an Amazon Machine Image (AMI).

    Example Usage

    AWS Account ID

    import * as pulumi from "@pulumi/pulumi";
    import * as aws from "@pulumi/aws";
    
    const example = new aws.ec2.AmiLaunchPermission("example", {
        imageId: "ami-12345678",
        accountId: "123456789012",
    });
    
    import pulumi
    import pulumi_aws as aws
    
    example = aws.ec2.AmiLaunchPermission("example",
        image_id="ami-12345678",
        account_id="123456789012")
    
    package main
    
    import (
    	"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/ec2"
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    )
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		_, err := ec2.NewAmiLaunchPermission(ctx, "example", &ec2.AmiLaunchPermissionArgs{
    			ImageId:   pulumi.String("ami-12345678"),
    			AccountId: pulumi.String("123456789012"),
    		})
    		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 example = new Aws.Ec2.AmiLaunchPermission("example", new()
        {
            ImageId = "ami-12345678",
            AccountId = "123456789012",
        });
    
    });
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.aws.ec2.AmiLaunchPermission;
    import com.pulumi.aws.ec2.AmiLaunchPermissionArgs;
    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 example = new AmiLaunchPermission("example", AmiLaunchPermissionArgs.builder()
                .imageId("ami-12345678")
                .accountId("123456789012")
                .build());
    
        }
    }
    
    resources:
      example:
        type: aws:ec2:AmiLaunchPermission
        properties:
          imageId: ami-12345678
          accountId: '123456789012'
    

    Public Access

    import * as pulumi from "@pulumi/pulumi";
    import * as aws from "@pulumi/aws";
    
    const example = new aws.ec2.AmiLaunchPermission("example", {
        imageId: "ami-12345678",
        group: "all",
    });
    
    import pulumi
    import pulumi_aws as aws
    
    example = aws.ec2.AmiLaunchPermission("example",
        image_id="ami-12345678",
        group="all")
    
    package main
    
    import (
    	"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/ec2"
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    )
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		_, err := ec2.NewAmiLaunchPermission(ctx, "example", &ec2.AmiLaunchPermissionArgs{
    			ImageId: pulumi.String("ami-12345678"),
    			Group:   pulumi.String("all"),
    		})
    		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 example = new Aws.Ec2.AmiLaunchPermission("example", new()
        {
            ImageId = "ami-12345678",
            Group = "all",
        });
    
    });
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.aws.ec2.AmiLaunchPermission;
    import com.pulumi.aws.ec2.AmiLaunchPermissionArgs;
    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 example = new AmiLaunchPermission("example", AmiLaunchPermissionArgs.builder()
                .imageId("ami-12345678")
                .group("all")
                .build());
    
        }
    }
    
    resources:
      example:
        type: aws:ec2:AmiLaunchPermission
        properties:
          imageId: ami-12345678
          group: all
    

    Organization Access

    import * as pulumi from "@pulumi/pulumi";
    import * as aws from "@pulumi/aws";
    
    const current = aws.organizations.getOrganization({});
    const example = new aws.ec2.AmiLaunchPermission("example", {
        imageId: "ami-12345678",
        organizationArn: current.then(current => current.arn),
    });
    
    import pulumi
    import pulumi_aws as aws
    
    current = aws.organizations.get_organization()
    example = aws.ec2.AmiLaunchPermission("example",
        image_id="ami-12345678",
        organization_arn=current.arn)
    
    package main
    
    import (
    	"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/ec2"
    	"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/organizations"
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    )
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		current, err := organizations.LookupOrganization(ctx, map[string]interface{}{}, nil)
    		if err != nil {
    			return err
    		}
    		_, err = ec2.NewAmiLaunchPermission(ctx, "example", &ec2.AmiLaunchPermissionArgs{
    			ImageId:         pulumi.String("ami-12345678"),
    			OrganizationArn: pulumi.String(current.Arn),
    		})
    		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 current = Aws.Organizations.GetOrganization.Invoke();
    
        var example = new Aws.Ec2.AmiLaunchPermission("example", new()
        {
            ImageId = "ami-12345678",
            OrganizationArn = current.Apply(getOrganizationResult => getOrganizationResult.Arn),
        });
    
    });
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.aws.organizations.OrganizationsFunctions;
    import com.pulumi.aws.ec2.AmiLaunchPermission;
    import com.pulumi.aws.ec2.AmiLaunchPermissionArgs;
    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 current = OrganizationsFunctions.getOrganization();
    
            var example = new AmiLaunchPermission("example", AmiLaunchPermissionArgs.builder()
                .imageId("ami-12345678")
                .organizationArn(current.applyValue(getOrganizationResult -> getOrganizationResult.arn()))
                .build());
    
        }
    }
    
    resources:
      example:
        type: aws:ec2:AmiLaunchPermission
        properties:
          imageId: ami-12345678
          organizationArn: ${current.arn}
    variables:
      current:
        fn::invoke:
          Function: aws:organizations:getOrganization
          Arguments: {}
    

    Create AmiLaunchPermission Resource

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

    Constructor syntax

    new AmiLaunchPermission(name: string, args: AmiLaunchPermissionArgs, opts?: CustomResourceOptions);
    @overload
    def AmiLaunchPermission(resource_name: str,
                            args: AmiLaunchPermissionArgs,
                            opts: Optional[ResourceOptions] = None)
    
    @overload
    def AmiLaunchPermission(resource_name: str,
                            opts: Optional[ResourceOptions] = None,
                            image_id: Optional[str] = None,
                            account_id: Optional[str] = None,
                            group: Optional[str] = None,
                            organization_arn: Optional[str] = None,
                            organizational_unit_arn: Optional[str] = None)
    func NewAmiLaunchPermission(ctx *Context, name string, args AmiLaunchPermissionArgs, opts ...ResourceOption) (*AmiLaunchPermission, error)
    public AmiLaunchPermission(string name, AmiLaunchPermissionArgs args, CustomResourceOptions? opts = null)
    public AmiLaunchPermission(String name, AmiLaunchPermissionArgs args)
    public AmiLaunchPermission(String name, AmiLaunchPermissionArgs args, CustomResourceOptions options)
    
    type: aws:ec2:AmiLaunchPermission
    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 AmiLaunchPermissionArgs
    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 AmiLaunchPermissionArgs
    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 AmiLaunchPermissionArgs
    The arguments to resource properties.
    opts ResourceOption
    Bag of options to control resource's behavior.
    name string
    The unique name of the resource.
    args AmiLaunchPermissionArgs
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    name String
    The unique name of the resource.
    args AmiLaunchPermissionArgs
    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 amiLaunchPermissionResource = new Aws.Ec2.AmiLaunchPermission("amiLaunchPermissionResource", new()
    {
        ImageId = "string",
        AccountId = "string",
        Group = "string",
        OrganizationArn = "string",
        OrganizationalUnitArn = "string",
    });
    
    example, err := ec2.NewAmiLaunchPermission(ctx, "amiLaunchPermissionResource", &ec2.AmiLaunchPermissionArgs{
    	ImageId:               pulumi.String("string"),
    	AccountId:             pulumi.String("string"),
    	Group:                 pulumi.String("string"),
    	OrganizationArn:       pulumi.String("string"),
    	OrganizationalUnitArn: pulumi.String("string"),
    })
    
    var amiLaunchPermissionResource = new AmiLaunchPermission("amiLaunchPermissionResource", AmiLaunchPermissionArgs.builder()
        .imageId("string")
        .accountId("string")
        .group("string")
        .organizationArn("string")
        .organizationalUnitArn("string")
        .build());
    
    ami_launch_permission_resource = aws.ec2.AmiLaunchPermission("amiLaunchPermissionResource",
        image_id="string",
        account_id="string",
        group="string",
        organization_arn="string",
        organizational_unit_arn="string")
    
    const amiLaunchPermissionResource = new aws.ec2.AmiLaunchPermission("amiLaunchPermissionResource", {
        imageId: "string",
        accountId: "string",
        group: "string",
        organizationArn: "string",
        organizationalUnitArn: "string",
    });
    
    type: aws:ec2:AmiLaunchPermission
    properties:
        accountId: string
        group: string
        imageId: string
        organizationArn: string
        organizationalUnitArn: string
    

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

    ImageId string
    ID of the AMI.
    AccountId string
    AWS account ID for the launch permission.
    Group string
    Name of the group for the launch permission. Valid values: "all".
    OrganizationArn string
    ARN of an organization for the launch permission.
    OrganizationalUnitArn string
    ARN of an organizational unit for the launch permission.
    ImageId string
    ID of the AMI.
    AccountId string
    AWS account ID for the launch permission.
    Group string
    Name of the group for the launch permission. Valid values: "all".
    OrganizationArn string
    ARN of an organization for the launch permission.
    OrganizationalUnitArn string
    ARN of an organizational unit for the launch permission.
    imageId String
    ID of the AMI.
    accountId String
    AWS account ID for the launch permission.
    group String
    Name of the group for the launch permission. Valid values: "all".
    organizationArn String
    ARN of an organization for the launch permission.
    organizationalUnitArn String
    ARN of an organizational unit for the launch permission.
    imageId string
    ID of the AMI.
    accountId string
    AWS account ID for the launch permission.
    group string
    Name of the group for the launch permission. Valid values: "all".
    organizationArn string
    ARN of an organization for the launch permission.
    organizationalUnitArn string
    ARN of an organizational unit for the launch permission.
    image_id str
    ID of the AMI.
    account_id str
    AWS account ID for the launch permission.
    group str
    Name of the group for the launch permission. Valid values: "all".
    organization_arn str
    ARN of an organization for the launch permission.
    organizational_unit_arn str
    ARN of an organizational unit for the launch permission.
    imageId String
    ID of the AMI.
    accountId String
    AWS account ID for the launch permission.
    group String
    Name of the group for the launch permission. Valid values: "all".
    organizationArn String
    ARN of an organization for the launch permission.
    organizationalUnitArn String
    ARN of an organizational unit for the launch permission.

    Outputs

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

    Get an existing AmiLaunchPermission 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?: AmiLaunchPermissionState, opts?: CustomResourceOptions): AmiLaunchPermission
    @staticmethod
    def get(resource_name: str,
            id: str,
            opts: Optional[ResourceOptions] = None,
            account_id: Optional[str] = None,
            group: Optional[str] = None,
            image_id: Optional[str] = None,
            organization_arn: Optional[str] = None,
            organizational_unit_arn: Optional[str] = None) -> AmiLaunchPermission
    func GetAmiLaunchPermission(ctx *Context, name string, id IDInput, state *AmiLaunchPermissionState, opts ...ResourceOption) (*AmiLaunchPermission, error)
    public static AmiLaunchPermission Get(string name, Input<string> id, AmiLaunchPermissionState? state, CustomResourceOptions? opts = null)
    public static AmiLaunchPermission get(String name, Output<String> id, AmiLaunchPermissionState 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:
    AccountId string
    AWS account ID for the launch permission.
    Group string
    Name of the group for the launch permission. Valid values: "all".
    ImageId string
    ID of the AMI.
    OrganizationArn string
    ARN of an organization for the launch permission.
    OrganizationalUnitArn string
    ARN of an organizational unit for the launch permission.
    AccountId string
    AWS account ID for the launch permission.
    Group string
    Name of the group for the launch permission. Valid values: "all".
    ImageId string
    ID of the AMI.
    OrganizationArn string
    ARN of an organization for the launch permission.
    OrganizationalUnitArn string
    ARN of an organizational unit for the launch permission.
    accountId String
    AWS account ID for the launch permission.
    group String
    Name of the group for the launch permission. Valid values: "all".
    imageId String
    ID of the AMI.
    organizationArn String
    ARN of an organization for the launch permission.
    organizationalUnitArn String
    ARN of an organizational unit for the launch permission.
    accountId string
    AWS account ID for the launch permission.
    group string
    Name of the group for the launch permission. Valid values: "all".
    imageId string
    ID of the AMI.
    organizationArn string
    ARN of an organization for the launch permission.
    organizationalUnitArn string
    ARN of an organizational unit for the launch permission.
    account_id str
    AWS account ID for the launch permission.
    group str
    Name of the group for the launch permission. Valid values: "all".
    image_id str
    ID of the AMI.
    organization_arn str
    ARN of an organization for the launch permission.
    organizational_unit_arn str
    ARN of an organizational unit for the launch permission.
    accountId String
    AWS account ID for the launch permission.
    group String
    Name of the group for the launch permission. Valid values: "all".
    imageId String
    ID of the AMI.
    organizationArn String
    ARN of an organization for the launch permission.
    organizationalUnitArn String
    ARN of an organizational unit for the launch permission.

    Import

    Using pulumi import, import AMI Launch Permissions using [ACCOUNT-ID|GROUP-NAME|ORGANIZATION-ARN|ORGANIZATIONAL-UNIT-ARN]/IMAGE-ID. For example:

    $ pulumi import aws:ec2/amiLaunchPermission:AmiLaunchPermission example 123456789012/ami-12345678
    

    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.60.0 published on Tuesday, Nov 19, 2024 by Pulumi