Show / Hide Table of Contents

Class SecGroup

Manages a V2 security group resource within OpenStack.

Please note that managing security groups through the OpenStack Compute API has been deprecated. Unless you are using an older OpenStack environment, it is recommended to use the openstack.networking.SecGroup and openstack.networking.SecGroupRule resources instead, which uses the OpenStack Networking API.

Example Usage

using Pulumi;
using OpenStack = Pulumi.OpenStack;

class MyStack : Stack
{
public MyStack()
{
    var secgroup1 = new OpenStack.Compute.SecGroup("secgroup1", new OpenStack.Compute.SecGroupArgs
    {
        Description = "my security group",
        Rules = 
        {
            new OpenStack.Compute.Inputs.SecGroupRuleArgs
            {
                Cidr = "0.0.0.0/0",
                FromPort = 22,
                IpProtocol = "tcp",
                ToPort = 22,
            },
            new OpenStack.Compute.Inputs.SecGroupRuleArgs
            {
                Cidr = "0.0.0.0/0",
                FromPort = 80,
                IpProtocol = "tcp",
                ToPort = 80,
            },
        },
    });
}

}

Notes

ICMP Rules

When using ICMP as the ip_protocol, the from_port sets the ICMP type and the to_port sets the ICMP code. To allow all ICMP types, set each value to -1, like so:

using Pulumi;

class MyStack : Stack
{
public MyStack()
{
}

}

A list of ICMP types and codes can be found here.

Referencing Security Groups

When referencing a security group in a configuration (for example, a configuration creates a new security group and then needs to apply it to an instance being created in the same configuration), it is currently recommended to reference the security group by name and not by ID, like this:

using Pulumi;
using OpenStack = Pulumi.OpenStack;

class MyStack : Stack
{
public MyStack()
{
    var test_server = new OpenStack.Compute.Instance("test-server", new OpenStack.Compute.InstanceArgs
    {
        FlavorId = "3",
        ImageId = "ad091b52-742f-469e-8f3c-fd81cadf0743",
        KeyPair = "my_key_pair_name",
        SecurityGroups = 
        {
            openstack_compute_secgroup_v2.Secgroup_1.Name,
        },
    });
}

}
Inheritance
System.Object
Resource
CustomResource
SecGroup
Inherited Members
CustomResource.Id
Resource.GetResourceType()
Resource.GetResourceName()
Resource.Urn
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.ToString()
Namespace: Pulumi.OpenStack.Compute
Assembly: Pulumi.OpenStack.dll
Syntax
public class SecGroup : CustomResource

Constructors

View Source

SecGroup(String, SecGroupArgs, CustomResourceOptions)

Create a SecGroup resource with the given unique name, arguments, and options.

Declaration
public SecGroup(string name, SecGroupArgs args, CustomResourceOptions options = null)
Parameters
Type Name Description
System.String name

The unique name of the resource

SecGroupArgs args

The arguments used to populate this resource's properties

CustomResourceOptions options

A bag of options that control this resource's behavior

Properties

View Source

Description

A description for the security group. Changing this updates the description of an existing security group.

Declaration
public Output<string> Description { get; }
Property Value
Type Description
Output<System.String>
View Source

Name

A unique name for the security group. Changing this updates the name of an existing security group.

Declaration
public Output<string> Name { get; }
Property Value
Type Description
Output<System.String>
View Source

Region

The region in which to obtain the V2 Compute client. A Compute client is needed to create a security group. If omitted, the region argument of the provider is used. Changing this creates a new security group.

Declaration
public Output<string> Region { get; }
Property Value
Type Description
Output<System.String>
View Source

Rules

A rule describing how the security group operates. The rule object structure is documented below. Changing this updates the security group rules. As shown in the example above, multiple rule blocks may be used.

Declaration
public Output<ImmutableArray<SecGroupRule>> Rules { get; }
Property Value
Type Description
Output<System.Collections.Immutable.ImmutableArray<SecGroupRule>>

Methods

View Source

Get(String, Input<String>, SecGroupState, CustomResourceOptions)

Get an existing SecGroup resource's state with the given name, ID, and optional extra properties used to qualify the lookup.

Declaration
public static SecGroup Get(string name, Input<string> id, SecGroupState state = null, CustomResourceOptions options = null)
Parameters
Type Name Description
System.String name

The unique name of the resulting resource.

Input<System.String> id

The unique provider ID of the resource to lookup.

SecGroupState state

Any extra arguments used during the lookup.

CustomResourceOptions options

A bag of options that control this resource's behavior

Returns
Type Description
SecGroup
  • View Source
Back to top Copyright 2016-2020, Pulumi Corporation.