1. Packages
  2. Alibaba Cloud
  3. API Docs
  4. ecs
  5. SecurityGroup
Alibaba Cloud v3.59.0 published on Friday, Jul 12, 2024 by Pulumi

alicloud.ecs.SecurityGroup

Explore with Pulumi AI

alicloud logo
Alibaba Cloud v3.59.0 published on Friday, Jul 12, 2024 by Pulumi

    Provides a Security Group resource.

    For information about Security Group and how to use it, see What is Security Group.

    NOTE: Available since v1.0.0.

    NOTE: alicloud.ecs.SecurityGroup is used to build and manage a security group, and alicloud.ecs.SecurityGroupRule can define ingress or egress rules for it.

    NOTE: From version 1.7.2, alicloud.ecs.SecurityGroup has supported to segregate different ECS instance in which the same security group.

    Example Usage

    Basic Usage

    import * as pulumi from "@pulumi/pulumi";
    import * as alicloud from "@pulumi/alicloud";
    
    const _default = new alicloud.ecs.SecurityGroup("default", {
        name: "terraform-example",
        description: "New security group",
    });
    
    import pulumi
    import pulumi_alicloud as alicloud
    
    default = alicloud.ecs.SecurityGroup("default",
        name="terraform-example",
        description="New security group")
    
    package main
    
    import (
    	"github.com/pulumi/pulumi-alicloud/sdk/v3/go/alicloud/ecs"
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    )
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		_, err := ecs.NewSecurityGroup(ctx, "default", &ecs.SecurityGroupArgs{
    			Name:        pulumi.String("terraform-example"),
    			Description: pulumi.String("New security group"),
    		})
    		if err != nil {
    			return err
    		}
    		return nil
    	})
    }
    
    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using AliCloud = Pulumi.AliCloud;
    
    return await Deployment.RunAsync(() => 
    {
        var @default = new AliCloud.Ecs.SecurityGroup("default", new()
        {
            Name = "terraform-example",
            Description = "New security group",
        });
    
    });
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.alicloud.ecs.SecurityGroup;
    import com.pulumi.alicloud.ecs.SecurityGroupArgs;
    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 default_ = new SecurityGroup("default", SecurityGroupArgs.builder()
                .name("terraform-example")
                .description("New security group")
                .build());
    
        }
    }
    
    resources:
      default:
        type: alicloud:ecs:SecurityGroup
        properties:
          name: terraform-example
          description: New security group
    

    Basic Usage for VPC

    import * as pulumi from "@pulumi/pulumi";
    import * as alicloud from "@pulumi/alicloud";
    
    const vpc = new alicloud.vpc.Network("vpc", {
        vpcName: "terraform-example",
        cidrBlock: "10.1.0.0/21",
    });
    const group = new alicloud.ecs.SecurityGroup("group", {
        name: "terraform-example",
        vpcId: vpc.id,
    });
    
    import pulumi
    import pulumi_alicloud as alicloud
    
    vpc = alicloud.vpc.Network("vpc",
        vpc_name="terraform-example",
        cidr_block="10.1.0.0/21")
    group = alicloud.ecs.SecurityGroup("group",
        name="terraform-example",
        vpc_id=vpc.id)
    
    package main
    
    import (
    	"github.com/pulumi/pulumi-alicloud/sdk/v3/go/alicloud/ecs"
    	"github.com/pulumi/pulumi-alicloud/sdk/v3/go/alicloud/vpc"
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    )
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		vpc, err := vpc.NewNetwork(ctx, "vpc", &vpc.NetworkArgs{
    			VpcName:   pulumi.String("terraform-example"),
    			CidrBlock: pulumi.String("10.1.0.0/21"),
    		})
    		if err != nil {
    			return err
    		}
    		_, err = ecs.NewSecurityGroup(ctx, "group", &ecs.SecurityGroupArgs{
    			Name:  pulumi.String("terraform-example"),
    			VpcId: vpc.ID(),
    		})
    		if err != nil {
    			return err
    		}
    		return nil
    	})
    }
    
    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using AliCloud = Pulumi.AliCloud;
    
    return await Deployment.RunAsync(() => 
    {
        var vpc = new AliCloud.Vpc.Network("vpc", new()
        {
            VpcName = "terraform-example",
            CidrBlock = "10.1.0.0/21",
        });
    
        var @group = new AliCloud.Ecs.SecurityGroup("group", new()
        {
            Name = "terraform-example",
            VpcId = vpc.Id,
        });
    
    });
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.alicloud.vpc.Network;
    import com.pulumi.alicloud.vpc.NetworkArgs;
    import com.pulumi.alicloud.ecs.SecurityGroup;
    import com.pulumi.alicloud.ecs.SecurityGroupArgs;
    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 vpc = new Network("vpc", NetworkArgs.builder()
                .vpcName("terraform-example")
                .cidrBlock("10.1.0.0/21")
                .build());
    
            var group = new SecurityGroup("group", SecurityGroupArgs.builder()
                .name("terraform-example")
                .vpcId(vpc.id())
                .build());
    
        }
    }
    
    resources:
      vpc:
        type: alicloud:vpc:Network
        properties:
          vpcName: terraform-example
          cidrBlock: 10.1.0.0/21
      group:
        type: alicloud:ecs:SecurityGroup
        properties:
          name: terraform-example
          vpcId: ${vpc.id}
    

    Module Support

    You can use the existing security-group module to create a security group and add several rules one-click.

    Create SecurityGroup Resource

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

    Constructor syntax

    new SecurityGroup(name: string, args?: SecurityGroupArgs, opts?: CustomResourceOptions);
    @overload
    def SecurityGroup(resource_name: str,
                      args: Optional[SecurityGroupArgs] = None,
                      opts: Optional[ResourceOptions] = None)
    
    @overload
    def SecurityGroup(resource_name: str,
                      opts: Optional[ResourceOptions] = None,
                      description: Optional[str] = None,
                      inner_access: Optional[bool] = None,
                      inner_access_policy: Optional[str] = None,
                      name: Optional[str] = None,
                      resource_group_id: Optional[str] = None,
                      security_group_type: Optional[str] = None,
                      tags: Optional[Mapping[str, Any]] = None,
                      vpc_id: Optional[str] = None)
    func NewSecurityGroup(ctx *Context, name string, args *SecurityGroupArgs, opts ...ResourceOption) (*SecurityGroup, error)
    public SecurityGroup(string name, SecurityGroupArgs? args = null, CustomResourceOptions? opts = null)
    public SecurityGroup(String name, SecurityGroupArgs args)
    public SecurityGroup(String name, SecurityGroupArgs args, CustomResourceOptions options)
    
    type: alicloud:ecs:SecurityGroup
    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 SecurityGroupArgs
    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 SecurityGroupArgs
    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 SecurityGroupArgs
    The arguments to resource properties.
    opts ResourceOption
    Bag of options to control resource's behavior.
    name string
    The unique name of the resource.
    args SecurityGroupArgs
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    name String
    The unique name of the resource.
    args SecurityGroupArgs
    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 securityGroupResource = new AliCloud.Ecs.SecurityGroup("securityGroupResource", new()
    {
        Description = "string",
        InnerAccessPolicy = "string",
        Name = "string",
        ResourceGroupId = "string",
        SecurityGroupType = "string",
        Tags = 
        {
            { "string", "any" },
        },
        VpcId = "string",
    });
    
    example, err := ecs.NewSecurityGroup(ctx, "securityGroupResource", &ecs.SecurityGroupArgs{
    	Description:       pulumi.String("string"),
    	InnerAccessPolicy: pulumi.String("string"),
    	Name:              pulumi.String("string"),
    	ResourceGroupId:   pulumi.String("string"),
    	SecurityGroupType: pulumi.String("string"),
    	Tags: pulumi.Map{
    		"string": pulumi.Any("any"),
    	},
    	VpcId: pulumi.String("string"),
    })
    
    var securityGroupResource = new SecurityGroup("securityGroupResource", SecurityGroupArgs.builder()
        .description("string")
        .innerAccessPolicy("string")
        .name("string")
        .resourceGroupId("string")
        .securityGroupType("string")
        .tags(Map.of("string", "any"))
        .vpcId("string")
        .build());
    
    security_group_resource = alicloud.ecs.SecurityGroup("securityGroupResource",
        description="string",
        inner_access_policy="string",
        name="string",
        resource_group_id="string",
        security_group_type="string",
        tags={
            "string": "any",
        },
        vpc_id="string")
    
    const securityGroupResource = new alicloud.ecs.SecurityGroup("securityGroupResource", {
        description: "string",
        innerAccessPolicy: "string",
        name: "string",
        resourceGroupId: "string",
        securityGroupType: "string",
        tags: {
            string: "any",
        },
        vpcId: "string",
    });
    
    type: alicloud:ecs:SecurityGroup
    properties:
        description: string
        innerAccessPolicy: string
        name: string
        resourceGroupId: string
        securityGroupType: string
        tags:
            string: any
        vpcId: string
    

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

    Description string
    The security group description. Defaults to null.
    InnerAccess bool

    Field inner_access has been deprecated from provider version 1.55.3. New field inner_access_policy instead.

    Combining security group rules, the policy can define multiple application scenario. Default to true. It is valid from version 1.7.2.

    Deprecated: Field inner_access has been deprecated from provider version 1.55.3. Use inner_access_policy replaces it.

    InnerAccessPolicy string
    The internal access control policy of the security group. Valid values: Accept, Drop.
    Name string
    The name of the security group. Defaults to null.
    ResourceGroupId string
    The ID of the resource group to which the security group belongs. NOTE: From version 1.115.0, resource_group_id can be modified.
    SecurityGroupType string
    The type of the security group. Valid values:
    Tags Dictionary<string, object>
    A mapping of tags to assign to the resource.
    VpcId string
    The ID of the VPC.
    Description string
    The security group description. Defaults to null.
    InnerAccess bool

    Field inner_access has been deprecated from provider version 1.55.3. New field inner_access_policy instead.

    Combining security group rules, the policy can define multiple application scenario. Default to true. It is valid from version 1.7.2.

    Deprecated: Field inner_access has been deprecated from provider version 1.55.3. Use inner_access_policy replaces it.

    InnerAccessPolicy string
    The internal access control policy of the security group. Valid values: Accept, Drop.
    Name string
    The name of the security group. Defaults to null.
    ResourceGroupId string
    The ID of the resource group to which the security group belongs. NOTE: From version 1.115.0, resource_group_id can be modified.
    SecurityGroupType string
    The type of the security group. Valid values:
    Tags map[string]interface{}
    A mapping of tags to assign to the resource.
    VpcId string
    The ID of the VPC.
    description String
    The security group description. Defaults to null.
    innerAccess Boolean

    Field inner_access has been deprecated from provider version 1.55.3. New field inner_access_policy instead.

    Combining security group rules, the policy can define multiple application scenario. Default to true. It is valid from version 1.7.2.

    Deprecated: Field inner_access has been deprecated from provider version 1.55.3. Use inner_access_policy replaces it.

    innerAccessPolicy String
    The internal access control policy of the security group. Valid values: Accept, Drop.
    name String
    The name of the security group. Defaults to null.
    resourceGroupId String
    The ID of the resource group to which the security group belongs. NOTE: From version 1.115.0, resource_group_id can be modified.
    securityGroupType String
    The type of the security group. Valid values:
    tags Map<String,Object>
    A mapping of tags to assign to the resource.
    vpcId String
    The ID of the VPC.
    description string
    The security group description. Defaults to null.
    innerAccess boolean

    Field inner_access has been deprecated from provider version 1.55.3. New field inner_access_policy instead.

    Combining security group rules, the policy can define multiple application scenario. Default to true. It is valid from version 1.7.2.

    Deprecated: Field inner_access has been deprecated from provider version 1.55.3. Use inner_access_policy replaces it.

    innerAccessPolicy string
    The internal access control policy of the security group. Valid values: Accept, Drop.
    name string
    The name of the security group. Defaults to null.
    resourceGroupId string
    The ID of the resource group to which the security group belongs. NOTE: From version 1.115.0, resource_group_id can be modified.
    securityGroupType string
    The type of the security group. Valid values:
    tags {[key: string]: any}
    A mapping of tags to assign to the resource.
    vpcId string
    The ID of the VPC.
    description str
    The security group description. Defaults to null.
    inner_access bool

    Field inner_access has been deprecated from provider version 1.55.3. New field inner_access_policy instead.

    Combining security group rules, the policy can define multiple application scenario. Default to true. It is valid from version 1.7.2.

    Deprecated: Field inner_access has been deprecated from provider version 1.55.3. Use inner_access_policy replaces it.

    inner_access_policy str
    The internal access control policy of the security group. Valid values: Accept, Drop.
    name str
    The name of the security group. Defaults to null.
    resource_group_id str
    The ID of the resource group to which the security group belongs. NOTE: From version 1.115.0, resource_group_id can be modified.
    security_group_type str
    The type of the security group. Valid values:
    tags Mapping[str, Any]
    A mapping of tags to assign to the resource.
    vpc_id str
    The ID of the VPC.
    description String
    The security group description. Defaults to null.
    innerAccess Boolean

    Field inner_access has been deprecated from provider version 1.55.3. New field inner_access_policy instead.

    Combining security group rules, the policy can define multiple application scenario. Default to true. It is valid from version 1.7.2.

    Deprecated: Field inner_access has been deprecated from provider version 1.55.3. Use inner_access_policy replaces it.

    innerAccessPolicy String
    The internal access control policy of the security group. Valid values: Accept, Drop.
    name String
    The name of the security group. Defaults to null.
    resourceGroupId String
    The ID of the resource group to which the security group belongs. NOTE: From version 1.115.0, resource_group_id can be modified.
    securityGroupType String
    The type of the security group. Valid values:
    tags Map<Any>
    A mapping of tags to assign to the resource.
    vpcId String
    The ID of the VPC.

    Outputs

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

    Get an existing SecurityGroup 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?: SecurityGroupState, opts?: CustomResourceOptions): SecurityGroup
    @staticmethod
    def get(resource_name: str,
            id: str,
            opts: Optional[ResourceOptions] = None,
            description: Optional[str] = None,
            inner_access: Optional[bool] = None,
            inner_access_policy: Optional[str] = None,
            name: Optional[str] = None,
            resource_group_id: Optional[str] = None,
            security_group_type: Optional[str] = None,
            tags: Optional[Mapping[str, Any]] = None,
            vpc_id: Optional[str] = None) -> SecurityGroup
    func GetSecurityGroup(ctx *Context, name string, id IDInput, state *SecurityGroupState, opts ...ResourceOption) (*SecurityGroup, error)
    public static SecurityGroup Get(string name, Input<string> id, SecurityGroupState? state, CustomResourceOptions? opts = null)
    public static SecurityGroup get(String name, Output<String> id, SecurityGroupState 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:
    Description string
    The security group description. Defaults to null.
    InnerAccess bool

    Field inner_access has been deprecated from provider version 1.55.3. New field inner_access_policy instead.

    Combining security group rules, the policy can define multiple application scenario. Default to true. It is valid from version 1.7.2.

    Deprecated: Field inner_access has been deprecated from provider version 1.55.3. Use inner_access_policy replaces it.

    InnerAccessPolicy string
    The internal access control policy of the security group. Valid values: Accept, Drop.
    Name string
    The name of the security group. Defaults to null.
    ResourceGroupId string
    The ID of the resource group to which the security group belongs. NOTE: From version 1.115.0, resource_group_id can be modified.
    SecurityGroupType string
    The type of the security group. Valid values:
    Tags Dictionary<string, object>
    A mapping of tags to assign to the resource.
    VpcId string
    The ID of the VPC.
    Description string
    The security group description. Defaults to null.
    InnerAccess bool

    Field inner_access has been deprecated from provider version 1.55.3. New field inner_access_policy instead.

    Combining security group rules, the policy can define multiple application scenario. Default to true. It is valid from version 1.7.2.

    Deprecated: Field inner_access has been deprecated from provider version 1.55.3. Use inner_access_policy replaces it.

    InnerAccessPolicy string
    The internal access control policy of the security group. Valid values: Accept, Drop.
    Name string
    The name of the security group. Defaults to null.
    ResourceGroupId string
    The ID of the resource group to which the security group belongs. NOTE: From version 1.115.0, resource_group_id can be modified.
    SecurityGroupType string
    The type of the security group. Valid values:
    Tags map[string]interface{}
    A mapping of tags to assign to the resource.
    VpcId string
    The ID of the VPC.
    description String
    The security group description. Defaults to null.
    innerAccess Boolean

    Field inner_access has been deprecated from provider version 1.55.3. New field inner_access_policy instead.

    Combining security group rules, the policy can define multiple application scenario. Default to true. It is valid from version 1.7.2.

    Deprecated: Field inner_access has been deprecated from provider version 1.55.3. Use inner_access_policy replaces it.

    innerAccessPolicy String
    The internal access control policy of the security group. Valid values: Accept, Drop.
    name String
    The name of the security group. Defaults to null.
    resourceGroupId String
    The ID of the resource group to which the security group belongs. NOTE: From version 1.115.0, resource_group_id can be modified.
    securityGroupType String
    The type of the security group. Valid values:
    tags Map<String,Object>
    A mapping of tags to assign to the resource.
    vpcId String
    The ID of the VPC.
    description string
    The security group description. Defaults to null.
    innerAccess boolean

    Field inner_access has been deprecated from provider version 1.55.3. New field inner_access_policy instead.

    Combining security group rules, the policy can define multiple application scenario. Default to true. It is valid from version 1.7.2.

    Deprecated: Field inner_access has been deprecated from provider version 1.55.3. Use inner_access_policy replaces it.

    innerAccessPolicy string
    The internal access control policy of the security group. Valid values: Accept, Drop.
    name string
    The name of the security group. Defaults to null.
    resourceGroupId string
    The ID of the resource group to which the security group belongs. NOTE: From version 1.115.0, resource_group_id can be modified.
    securityGroupType string
    The type of the security group. Valid values:
    tags {[key: string]: any}
    A mapping of tags to assign to the resource.
    vpcId string
    The ID of the VPC.
    description str
    The security group description. Defaults to null.
    inner_access bool

    Field inner_access has been deprecated from provider version 1.55.3. New field inner_access_policy instead.

    Combining security group rules, the policy can define multiple application scenario. Default to true. It is valid from version 1.7.2.

    Deprecated: Field inner_access has been deprecated from provider version 1.55.3. Use inner_access_policy replaces it.

    inner_access_policy str
    The internal access control policy of the security group. Valid values: Accept, Drop.
    name str
    The name of the security group. Defaults to null.
    resource_group_id str
    The ID of the resource group to which the security group belongs. NOTE: From version 1.115.0, resource_group_id can be modified.
    security_group_type str
    The type of the security group. Valid values:
    tags Mapping[str, Any]
    A mapping of tags to assign to the resource.
    vpc_id str
    The ID of the VPC.
    description String
    The security group description. Defaults to null.
    innerAccess Boolean

    Field inner_access has been deprecated from provider version 1.55.3. New field inner_access_policy instead.

    Combining security group rules, the policy can define multiple application scenario. Default to true. It is valid from version 1.7.2.

    Deprecated: Field inner_access has been deprecated from provider version 1.55.3. Use inner_access_policy replaces it.

    innerAccessPolicy String
    The internal access control policy of the security group. Valid values: Accept, Drop.
    name String
    The name of the security group. Defaults to null.
    resourceGroupId String
    The ID of the resource group to which the security group belongs. NOTE: From version 1.115.0, resource_group_id can be modified.
    securityGroupType String
    The type of the security group. Valid values:
    tags Map<Any>
    A mapping of tags to assign to the resource.
    vpcId String
    The ID of the VPC.

    Import

    Security Group can be imported using the id, e.g.

    $ pulumi import alicloud:ecs/securityGroup:SecurityGroup example sg-abc123456
    

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

    Package Details

    Repository
    Alibaba Cloud pulumi/pulumi-alicloud
    License
    Apache-2.0
    Notes
    This Pulumi package is based on the alicloud Terraform Provider.
    alicloud logo
    Alibaba Cloud v3.59.0 published on Friday, Jul 12, 2024 by Pulumi