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

aws.ec2.SecurityGroupAssociation

Explore with Pulumi AI

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

    Provides a resource to create an association between a VPC endpoint and a security group.

    NOTE on VPC Endpoints and VPC Endpoint Security Group Associations: The provider provides both a standalone VPC Endpoint Security Group Association (an association between a VPC endpoint and a single security_group_id) and a VPC Endpoint resource with a security_group_ids attribute. Do not use the same security group ID in both a VPC Endpoint resource and a VPC Endpoint Security Group Association resource. Doing so will cause a conflict of associations and will overwrite the association.

    Example Usage

    Basic usage:

    import * as pulumi from "@pulumi/pulumi";
    import * as aws from "@pulumi/aws";
    
    const sgEc2 = new aws.ec2.SecurityGroupAssociation("sg_ec2", {
        vpcEndpointId: ec2.id,
        securityGroupId: sg.id,
    });
    
    import pulumi
    import pulumi_aws as aws
    
    sg_ec2 = aws.ec2.SecurityGroupAssociation("sg_ec2",
        vpc_endpoint_id=ec2["id"],
        security_group_id=sg["id"])
    
    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.NewSecurityGroupAssociation(ctx, "sg_ec2", &ec2.SecurityGroupAssociationArgs{
    			VpcEndpointId:   pulumi.Any(ec2.Id),
    			SecurityGroupId: pulumi.Any(sg.Id),
    		})
    		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 sgEc2 = new Aws.Ec2.SecurityGroupAssociation("sg_ec2", new()
        {
            VpcEndpointId = ec2.Id,
            SecurityGroupId = sg.Id,
        });
    
    });
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.aws.ec2.SecurityGroupAssociation;
    import com.pulumi.aws.ec2.SecurityGroupAssociationArgs;
    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 sgEc2 = new SecurityGroupAssociation("sgEc2", SecurityGroupAssociationArgs.builder()
                .vpcEndpointId(ec2.id())
                .securityGroupId(sg.id())
                .build());
    
        }
    }
    
    resources:
      sgEc2:
        type: aws:ec2:SecurityGroupAssociation
        name: sg_ec2
        properties:
          vpcEndpointId: ${ec2.id}
          securityGroupId: ${sg.id}
    

    Create SecurityGroupAssociation Resource

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

    Constructor syntax

    new SecurityGroupAssociation(name: string, args: SecurityGroupAssociationArgs, opts?: CustomResourceOptions);
    @overload
    def SecurityGroupAssociation(resource_name: str,
                                 args: SecurityGroupAssociationArgs,
                                 opts: Optional[ResourceOptions] = None)
    
    @overload
    def SecurityGroupAssociation(resource_name: str,
                                 opts: Optional[ResourceOptions] = None,
                                 security_group_id: Optional[str] = None,
                                 vpc_endpoint_id: Optional[str] = None,
                                 replace_default_association: Optional[bool] = None)
    func NewSecurityGroupAssociation(ctx *Context, name string, args SecurityGroupAssociationArgs, opts ...ResourceOption) (*SecurityGroupAssociation, error)
    public SecurityGroupAssociation(string name, SecurityGroupAssociationArgs args, CustomResourceOptions? opts = null)
    public SecurityGroupAssociation(String name, SecurityGroupAssociationArgs args)
    public SecurityGroupAssociation(String name, SecurityGroupAssociationArgs args, CustomResourceOptions options)
    
    type: aws:ec2:SecurityGroupAssociation
    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 SecurityGroupAssociationArgs
    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 SecurityGroupAssociationArgs
    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 SecurityGroupAssociationArgs
    The arguments to resource properties.
    opts ResourceOption
    Bag of options to control resource's behavior.
    name string
    The unique name of the resource.
    args SecurityGroupAssociationArgs
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    name String
    The unique name of the resource.
    args SecurityGroupAssociationArgs
    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 securityGroupAssociationResource = new Aws.Ec2.SecurityGroupAssociation("securityGroupAssociationResource", new()
    {
        SecurityGroupId = "string",
        VpcEndpointId = "string",
        ReplaceDefaultAssociation = false,
    });
    
    example, err := ec2.NewSecurityGroupAssociation(ctx, "securityGroupAssociationResource", &ec2.SecurityGroupAssociationArgs{
    	SecurityGroupId:           pulumi.String("string"),
    	VpcEndpointId:             pulumi.String("string"),
    	ReplaceDefaultAssociation: pulumi.Bool(false),
    })
    
    var securityGroupAssociationResource = new SecurityGroupAssociation("securityGroupAssociationResource", SecurityGroupAssociationArgs.builder()
        .securityGroupId("string")
        .vpcEndpointId("string")
        .replaceDefaultAssociation(false)
        .build());
    
    security_group_association_resource = aws.ec2.SecurityGroupAssociation("securityGroupAssociationResource",
        security_group_id="string",
        vpc_endpoint_id="string",
        replace_default_association=False)
    
    const securityGroupAssociationResource = new aws.ec2.SecurityGroupAssociation("securityGroupAssociationResource", {
        securityGroupId: "string",
        vpcEndpointId: "string",
        replaceDefaultAssociation: false,
    });
    
    type: aws:ec2:SecurityGroupAssociation
    properties:
        replaceDefaultAssociation: false
        securityGroupId: string
        vpcEndpointId: string
    

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

    SecurityGroupId string
    The ID of the security group to be associated with the VPC endpoint.
    VpcEndpointId string
    The ID of the VPC endpoint with which the security group will be associated.
    ReplaceDefaultAssociation bool
    Whether this association should replace the association with the VPC's default security group that is created when no security groups are specified during VPC endpoint creation. At most 1 association per-VPC endpoint should be configured with replace_default_association = true.
    SecurityGroupId string
    The ID of the security group to be associated with the VPC endpoint.
    VpcEndpointId string
    The ID of the VPC endpoint with which the security group will be associated.
    ReplaceDefaultAssociation bool
    Whether this association should replace the association with the VPC's default security group that is created when no security groups are specified during VPC endpoint creation. At most 1 association per-VPC endpoint should be configured with replace_default_association = true.
    securityGroupId String
    The ID of the security group to be associated with the VPC endpoint.
    vpcEndpointId String
    The ID of the VPC endpoint with which the security group will be associated.
    replaceDefaultAssociation Boolean
    Whether this association should replace the association with the VPC's default security group that is created when no security groups are specified during VPC endpoint creation. At most 1 association per-VPC endpoint should be configured with replace_default_association = true.
    securityGroupId string
    The ID of the security group to be associated with the VPC endpoint.
    vpcEndpointId string
    The ID of the VPC endpoint with which the security group will be associated.
    replaceDefaultAssociation boolean
    Whether this association should replace the association with the VPC's default security group that is created when no security groups are specified during VPC endpoint creation. At most 1 association per-VPC endpoint should be configured with replace_default_association = true.
    security_group_id str
    The ID of the security group to be associated with the VPC endpoint.
    vpc_endpoint_id str
    The ID of the VPC endpoint with which the security group will be associated.
    replace_default_association bool
    Whether this association should replace the association with the VPC's default security group that is created when no security groups are specified during VPC endpoint creation. At most 1 association per-VPC endpoint should be configured with replace_default_association = true.
    securityGroupId String
    The ID of the security group to be associated with the VPC endpoint.
    vpcEndpointId String
    The ID of the VPC endpoint with which the security group will be associated.
    replaceDefaultAssociation Boolean
    Whether this association should replace the association with the VPC's default security group that is created when no security groups are specified during VPC endpoint creation. At most 1 association per-VPC endpoint should be configured with replace_default_association = true.

    Outputs

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

    Get an existing SecurityGroupAssociation 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?: SecurityGroupAssociationState, opts?: CustomResourceOptions): SecurityGroupAssociation
    @staticmethod
    def get(resource_name: str,
            id: str,
            opts: Optional[ResourceOptions] = None,
            replace_default_association: Optional[bool] = None,
            security_group_id: Optional[str] = None,
            vpc_endpoint_id: Optional[str] = None) -> SecurityGroupAssociation
    func GetSecurityGroupAssociation(ctx *Context, name string, id IDInput, state *SecurityGroupAssociationState, opts ...ResourceOption) (*SecurityGroupAssociation, error)
    public static SecurityGroupAssociation Get(string name, Input<string> id, SecurityGroupAssociationState? state, CustomResourceOptions? opts = null)
    public static SecurityGroupAssociation get(String name, Output<String> id, SecurityGroupAssociationState 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:
    ReplaceDefaultAssociation bool
    Whether this association should replace the association with the VPC's default security group that is created when no security groups are specified during VPC endpoint creation. At most 1 association per-VPC endpoint should be configured with replace_default_association = true.
    SecurityGroupId string
    The ID of the security group to be associated with the VPC endpoint.
    VpcEndpointId string
    The ID of the VPC endpoint with which the security group will be associated.
    ReplaceDefaultAssociation bool
    Whether this association should replace the association with the VPC's default security group that is created when no security groups are specified during VPC endpoint creation. At most 1 association per-VPC endpoint should be configured with replace_default_association = true.
    SecurityGroupId string
    The ID of the security group to be associated with the VPC endpoint.
    VpcEndpointId string
    The ID of the VPC endpoint with which the security group will be associated.
    replaceDefaultAssociation Boolean
    Whether this association should replace the association with the VPC's default security group that is created when no security groups are specified during VPC endpoint creation. At most 1 association per-VPC endpoint should be configured with replace_default_association = true.
    securityGroupId String
    The ID of the security group to be associated with the VPC endpoint.
    vpcEndpointId String
    The ID of the VPC endpoint with which the security group will be associated.
    replaceDefaultAssociation boolean
    Whether this association should replace the association with the VPC's default security group that is created when no security groups are specified during VPC endpoint creation. At most 1 association per-VPC endpoint should be configured with replace_default_association = true.
    securityGroupId string
    The ID of the security group to be associated with the VPC endpoint.
    vpcEndpointId string
    The ID of the VPC endpoint with which the security group will be associated.
    replace_default_association bool
    Whether this association should replace the association with the VPC's default security group that is created when no security groups are specified during VPC endpoint creation. At most 1 association per-VPC endpoint should be configured with replace_default_association = true.
    security_group_id str
    The ID of the security group to be associated with the VPC endpoint.
    vpc_endpoint_id str
    The ID of the VPC endpoint with which the security group will be associated.
    replaceDefaultAssociation Boolean
    Whether this association should replace the association with the VPC's default security group that is created when no security groups are specified during VPC endpoint creation. At most 1 association per-VPC endpoint should be configured with replace_default_association = true.
    securityGroupId String
    The ID of the security group to be associated with the VPC endpoint.
    vpcEndpointId String
    The ID of the VPC endpoint with which the security group will be associated.

    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