Package com.pulumi.openstack.compute
Class SecGroup
- java.lang.Object
-
- com.pulumi.resources.Resource
-
- com.pulumi.resources.CustomResource
-
- com.pulumi.openstack.compute.SecGroup
-
public class SecGroup extends com.pulumi.resources.CustomResourceManages 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 ```java package generated_program; import com.pulumi.Context; import com.pulumi.Pulumi; import com.pulumi.core.Output; import com.pulumi.openstack.compute.SecGroup; import com.pulumi.openstack.compute.SecGroupArgs; import com.pulumi.openstack.compute.inputs.SecGroupRuleArgs; 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 secgroup1 = new SecGroup("secgroup1", SecGroupArgs.builder() .description("my security group") .rules( SecGroupRuleArgs.builder() .cidr("0.0.0.0/0") .fromPort(22) .ipProtocol("tcp") .toPort(22) .build(), SecGroupRuleArgs.builder() .cidr("0.0.0.0/0") .fromPort(80) .ipProtocol("tcp") .toPort(80) .build()) .build()); } } ``` ## 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: ```java package generated_program; import com.pulumi.Context; import com.pulumi.Pulumi; import com.pulumi.core.Output; 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) { } } ``` A list of ICMP types and codes can be found [here](https://en.wikipedia.org/wiki/Internet_Control_Message_Protocol#Control_messages). ### 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: ```java package generated_program; import com.pulumi.Context; import com.pulumi.Pulumi; import com.pulumi.core.Output; import com.pulumi.openstack.compute.Instance; import com.pulumi.openstack.compute.InstanceArgs; 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 test_server = new Instance("test-server", InstanceArgs.builder() .imageId("ad091b52-742f-469e-8f3c-fd81cadf0743") .flavorId("3") .keyPair("my_key_pair_name") .securityGroups(openstack_compute_secgroup_v2.secgroup_1().name()) .build()); } } ``` ## Import Security Groups can be imported using the `id`, e.g. ```sh $ pulumi import openstack:compute/secGroup:SecGroup my_secgroup 1bc30ee9-9d5b-4c30-bdd5-7f1e663f5edf ```
-
-
Constructor Summary
Constructors Constructor Description SecGroup(java.lang.String name)SecGroup(java.lang.String name, SecGroupArgs args)SecGroup(java.lang.String name, SecGroupArgs args, com.pulumi.resources.CustomResourceOptions options)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description com.pulumi.core.Output<java.lang.String>description()static SecGroupget(java.lang.String name, com.pulumi.core.Output<java.lang.String> id, SecGroupState state, com.pulumi.resources.CustomResourceOptions options)Get an existing Host resource's state with the given name, ID, and optional extra properties used to qualify the lookup.com.pulumi.core.Output<java.lang.String>name()com.pulumi.core.Output<java.lang.String>region()com.pulumi.core.Output<java.util.List<SecGroupRule>>rules()
-
-
-
Constructor Detail
-
SecGroup
public SecGroup(java.lang.String name)
- Parameters:
name- The _unique_ name of the resulting resource.
-
SecGroup
public SecGroup(java.lang.String name, SecGroupArgs args)- Parameters:
name- The _unique_ name of the resulting resource.args- The arguments to use to populate this resource's properties.
-
SecGroup
public SecGroup(java.lang.String name, SecGroupArgs args, @Nullable com.pulumi.resources.CustomResourceOptions options)- Parameters:
name- The _unique_ name of the resulting resource.args- The arguments to use to populate this resource's properties.options- A bag of options that control this resource's behavior.
-
-
Method Detail
-
description
public com.pulumi.core.Output<java.lang.String> description()
- Returns:
- A description for the security group. Changing this updates the `description` of an existing security group.
-
name
public com.pulumi.core.Output<java.lang.String> name()
- Returns:
- A unique name for the security group. Changing this updates the `name` of an existing security group.
-
region
public com.pulumi.core.Output<java.lang.String> region()
- Returns:
- 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.
-
rules
public com.pulumi.core.Output<java.util.List<SecGroupRule>> rules()
- Returns:
- 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.
-
get
public static SecGroup get(java.lang.String name, com.pulumi.core.Output<java.lang.String> id, @Nullable SecGroupState state, @Nullable com.pulumi.resources.CustomResourceOptions options)
Get an existing Host resource's state with the given name, ID, and optional extra properties used to qualify the lookup.- Parameters:
name- The _unique_ name of the resulting resource.id- The _unique_ provider ID of the resource to lookup.state-options- Optional settings to control the behavior of the CustomResource.
-
-