com.pulumi.azure.network.NetworkSecurityRule Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of azure Show documentation
Show all versions of azure Show documentation
A Pulumi package for creating and managing Microsoft Azure cloud resources, based on the Terraform azurerm provider. We recommend using the [Azure Native provider](https://github.com/pulumi/pulumi-azure-native) to provision Azure infrastructure. Azure Native provides complete coverage of Azure resources and same-day access to new resources and resource updates.
// *** WARNING: this file was generated by pulumi-java-gen. ***
// *** Do not edit by hand unless you're certain you know what you are doing! ***
package com.pulumi.azure.network;
import com.pulumi.azure.Utilities;
import com.pulumi.azure.network.NetworkSecurityRuleArgs;
import com.pulumi.azure.network.inputs.NetworkSecurityRuleState;
import com.pulumi.core.Output;
import com.pulumi.core.annotations.Export;
import com.pulumi.core.annotations.ResourceType;
import com.pulumi.core.internal.Codegen;
import java.lang.Integer;
import java.lang.String;
import java.util.List;
import java.util.Optional;
import javax.annotation.Nullable;
/**
* Manages a Network Security Rule.
*
* > **NOTE on Network Security Groups and Network Security Rules:** This provider currently
* provides both a standalone Network Security Rule resource, and allows for Network Security Rules to be defined in-line within the Network Security Group resource.
* At this time you cannot use a Network Security Group with in-line Network Security Rules in conjunction with any Network Security Rule resources. Doing so will cause a conflict of rule settings and will overwrite rules.
*
* ## Example Usage
*
* <!--Start PulumiCodeChooser -->
*
* {@code
* package generated_program;
*
* import com.pulumi.Context;
* import com.pulumi.Pulumi;
* import com.pulumi.core.Output;
* import com.pulumi.azure.core.ResourceGroup;
* import com.pulumi.azure.core.ResourceGroupArgs;
* import com.pulumi.azure.network.NetworkSecurityGroup;
* import com.pulumi.azure.network.NetworkSecurityGroupArgs;
* import com.pulumi.azure.network.NetworkSecurityRule;
* import com.pulumi.azure.network.NetworkSecurityRuleArgs;
* 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 ResourceGroup("example", ResourceGroupArgs.builder()
* .name("example-resources")
* .location("West Europe")
* .build());
*
* var exampleNetworkSecurityGroup = new NetworkSecurityGroup("exampleNetworkSecurityGroup", NetworkSecurityGroupArgs.builder()
* .name("acceptanceTestSecurityGroup1")
* .location(example.location())
* .resourceGroupName(example.name())
* .build());
*
* var exampleNetworkSecurityRule = new NetworkSecurityRule("exampleNetworkSecurityRule", NetworkSecurityRuleArgs.builder()
* .name("test123")
* .priority(100)
* .direction("Outbound")
* .access("Allow")
* .protocol("Tcp")
* .sourcePortRange("*")
* .destinationPortRange("*")
* .sourceAddressPrefix("*")
* .destinationAddressPrefix("*")
* .resourceGroupName(example.name())
* .networkSecurityGroupName(exampleNetworkSecurityGroup.name())
* .build());
*
* }
* }
* }
*
* <!--End PulumiCodeChooser -->
*
* ## Import
*
* Network Security Rules can be imported using the `resource id`, e.g.
*
* ```sh
* $ pulumi import azure:network/networkSecurityRule:NetworkSecurityRule rule1 /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/mygroup1/providers/Microsoft.Network/networkSecurityGroups/mySecurityGroup/securityRules/rule1
* ```
*
*/
@ResourceType(type="azure:network/networkSecurityRule:NetworkSecurityRule")
public class NetworkSecurityRule extends com.pulumi.resources.CustomResource {
/**
* Specifies whether network traffic is allowed or denied. Possible values are `Allow` and `Deny`.
*
*/
@Export(name="access", refs={String.class}, tree="[0]")
private Output access;
/**
* @return Specifies whether network traffic is allowed or denied. Possible values are `Allow` and `Deny`.
*
*/
public Output access() {
return this.access;
}
/**
* A description for this rule. Restricted to 140 characters.
*
*/
@Export(name="description", refs={String.class}, tree="[0]")
private Output* @Nullable */ String> description;
/**
* @return A description for this rule. Restricted to 140 characters.
*
*/
public Output> description() {
return Codegen.optional(this.description);
}
/**
* CIDR or destination IP range or * to match any IP. Tags such as `VirtualNetwork`, `AzureLoadBalancer` and `Internet` can also be used. Besides, it also supports all available Service Tags like ‘Sql.WestEurope‘, ‘Storage.EastUS‘, etc. You can list the available service tags with the CLI: ```shell az network list-service-tags --location westcentralus```. For further information please see [Azure CLI - az network list-service-tags](https://docs.microsoft.com/cli/azure/network?view=azure-cli-latest#az-network-list-service-tags). This is required if `destination_address_prefixes` is not specified.
*
*/
@Export(name="destinationAddressPrefix", refs={String.class}, tree="[0]")
private Output* @Nullable */ String> destinationAddressPrefix;
/**
* @return CIDR or destination IP range or * to match any IP. Tags such as `VirtualNetwork`, `AzureLoadBalancer` and `Internet` can also be used. Besides, it also supports all available Service Tags like ‘Sql.WestEurope‘, ‘Storage.EastUS‘, etc. You can list the available service tags with the CLI: ```shell az network list-service-tags --location westcentralus```. For further information please see [Azure CLI - az network list-service-tags](https://docs.microsoft.com/cli/azure/network?view=azure-cli-latest#az-network-list-service-tags). This is required if `destination_address_prefixes` is not specified.
*
*/
public Output> destinationAddressPrefix() {
return Codegen.optional(this.destinationAddressPrefix);
}
/**
* List of destination address prefixes. Tags may not be used. This is required if `destination_address_prefix` is not specified.
*
*/
@Export(name="destinationAddressPrefixes", refs={List.class,String.class}, tree="[0,1]")
private Output* @Nullable */ List> destinationAddressPrefixes;
/**
* @return List of destination address prefixes. Tags may not be used. This is required if `destination_address_prefix` is not specified.
*
*/
public Output>> destinationAddressPrefixes() {
return Codegen.optional(this.destinationAddressPrefixes);
}
/**
* A List of destination Application Security Group IDs
*
*/
@Export(name="destinationApplicationSecurityGroupIds", refs={String.class}, tree="[0]")
private Output* @Nullable */ String> destinationApplicationSecurityGroupIds;
/**
* @return A List of destination Application Security Group IDs
*
*/
public Output> destinationApplicationSecurityGroupIds() {
return Codegen.optional(this.destinationApplicationSecurityGroupIds);
}
/**
* Destination Port or Range. Integer or range between `0` and `65535` or `*` to match any. This is required if `destination_port_ranges` is not specified.
*
*/
@Export(name="destinationPortRange", refs={String.class}, tree="[0]")
private Output* @Nullable */ String> destinationPortRange;
/**
* @return Destination Port or Range. Integer or range between `0` and `65535` or `*` to match any. This is required if `destination_port_ranges` is not specified.
*
*/
public Output> destinationPortRange() {
return Codegen.optional(this.destinationPortRange);
}
/**
* List of destination ports or port ranges. This is required if `destination_port_range` is not specified.
*
*/
@Export(name="destinationPortRanges", refs={List.class,String.class}, tree="[0,1]")
private Output* @Nullable */ List> destinationPortRanges;
/**
* @return List of destination ports or port ranges. This is required if `destination_port_range` is not specified.
*
*/
public Output>> destinationPortRanges() {
return Codegen.optional(this.destinationPortRanges);
}
/**
* The direction specifies if rule will be evaluated on incoming or outgoing traffic. Possible values are `Inbound` and `Outbound`.
*
*/
@Export(name="direction", refs={String.class}, tree="[0]")
private Output direction;
/**
* @return The direction specifies if rule will be evaluated on incoming or outgoing traffic. Possible values are `Inbound` and `Outbound`.
*
*/
public Output direction() {
return this.direction;
}
/**
* The name of the security rule. This needs to be unique across all Rules in the Network Security Group. Changing this forces a new resource to be created.
*
*/
@Export(name="name", refs={String.class}, tree="[0]")
private Output name;
/**
* @return The name of the security rule. This needs to be unique across all Rules in the Network Security Group. Changing this forces a new resource to be created.
*
*/
public Output name() {
return this.name;
}
/**
* The name of the Network Security Group that we want to attach the rule to. Changing this forces a new resource to be created.
*
*/
@Export(name="networkSecurityGroupName", refs={String.class}, tree="[0]")
private Output networkSecurityGroupName;
/**
* @return The name of the Network Security Group that we want to attach the rule to. Changing this forces a new resource to be created.
*
*/
public Output networkSecurityGroupName() {
return this.networkSecurityGroupName;
}
/**
* Specifies the priority of the rule. The value can be between 100 and 4096. The priority number must be unique for each rule in the collection. The lower the priority number, the higher the priority of the rule.
*
*/
@Export(name="priority", refs={Integer.class}, tree="[0]")
private Output priority;
/**
* @return Specifies the priority of the rule. The value can be between 100 and 4096. The priority number must be unique for each rule in the collection. The lower the priority number, the higher the priority of the rule.
*
*/
public Output priority() {
return this.priority;
}
/**
* Network protocol this rule applies to. Possible values include `Tcp`, `Udp`, `Icmp`, `Esp`, `Ah` or `*` (which matches all).
*
*/
@Export(name="protocol", refs={String.class}, tree="[0]")
private Output protocol;
/**
* @return Network protocol this rule applies to. Possible values include `Tcp`, `Udp`, `Icmp`, `Esp`, `Ah` or `*` (which matches all).
*
*/
public Output protocol() {
return this.protocol;
}
/**
* The name of the resource group in which to create the Network Security Rule. Changing this forces a new resource to be created.
*
*/
@Export(name="resourceGroupName", refs={String.class}, tree="[0]")
private Output resourceGroupName;
/**
* @return The name of the resource group in which to create the Network Security Rule. Changing this forces a new resource to be created.
*
*/
public Output resourceGroupName() {
return this.resourceGroupName;
}
/**
* CIDR or source IP range or * to match any IP. Tags such as `VirtualNetwork`, `AzureLoadBalancer` and `Internet` can also be used. This is required if `source_address_prefixes` is not specified.
*
*/
@Export(name="sourceAddressPrefix", refs={String.class}, tree="[0]")
private Output* @Nullable */ String> sourceAddressPrefix;
/**
* @return CIDR or source IP range or * to match any IP. Tags such as `VirtualNetwork`, `AzureLoadBalancer` and `Internet` can also be used. This is required if `source_address_prefixes` is not specified.
*
*/
public Output> sourceAddressPrefix() {
return Codegen.optional(this.sourceAddressPrefix);
}
/**
* List of source address prefixes. Tags may not be used. This is required if `source_address_prefix` is not specified.
*
*/
@Export(name="sourceAddressPrefixes", refs={List.class,String.class}, tree="[0,1]")
private Output* @Nullable */ List> sourceAddressPrefixes;
/**
* @return List of source address prefixes. Tags may not be used. This is required if `source_address_prefix` is not specified.
*
*/
public Output>> sourceAddressPrefixes() {
return Codegen.optional(this.sourceAddressPrefixes);
}
/**
* A List of source Application Security Group IDs
*
*/
@Export(name="sourceApplicationSecurityGroupIds", refs={String.class}, tree="[0]")
private Output* @Nullable */ String> sourceApplicationSecurityGroupIds;
/**
* @return A List of source Application Security Group IDs
*
*/
public Output> sourceApplicationSecurityGroupIds() {
return Codegen.optional(this.sourceApplicationSecurityGroupIds);
}
/**
* Source Port or Range. Integer or range between `0` and `65535` or `*` to match any. This is required if `source_port_ranges` is not specified.
*
*/
@Export(name="sourcePortRange", refs={String.class}, tree="[0]")
private Output* @Nullable */ String> sourcePortRange;
/**
* @return Source Port or Range. Integer or range between `0` and `65535` or `*` to match any. This is required if `source_port_ranges` is not specified.
*
*/
public Output> sourcePortRange() {
return Codegen.optional(this.sourcePortRange);
}
/**
* List of source ports or port ranges. This is required if `source_port_range` is not specified.
*
*/
@Export(name="sourcePortRanges", refs={List.class,String.class}, tree="[0,1]")
private Output* @Nullable */ List> sourcePortRanges;
/**
* @return List of source ports or port ranges. This is required if `source_port_range` is not specified.
*
*/
public Output>> sourcePortRanges() {
return Codegen.optional(this.sourcePortRanges);
}
/**
*
* @param name The _unique_ name of the resulting resource.
*/
public NetworkSecurityRule(java.lang.String name) {
this(name, NetworkSecurityRuleArgs.Empty);
}
/**
*
* @param name The _unique_ name of the resulting resource.
* @param args The arguments to use to populate this resource's properties.
*/
public NetworkSecurityRule(java.lang.String name, NetworkSecurityRuleArgs args) {
this(name, args, null);
}
/**
*
* @param name The _unique_ name of the resulting resource.
* @param args The arguments to use to populate this resource's properties.
* @param options A bag of options that control this resource's behavior.
*/
public NetworkSecurityRule(java.lang.String name, NetworkSecurityRuleArgs args, @Nullable com.pulumi.resources.CustomResourceOptions options) {
super("azure:network/networkSecurityRule:NetworkSecurityRule", name, makeArgs(args, options), makeResourceOptions(options, Codegen.empty()), false);
}
private NetworkSecurityRule(java.lang.String name, Output id, @Nullable NetworkSecurityRuleState state, @Nullable com.pulumi.resources.CustomResourceOptions options) {
super("azure:network/networkSecurityRule:NetworkSecurityRule", name, state, makeResourceOptions(options, id), false);
}
private static NetworkSecurityRuleArgs makeArgs(NetworkSecurityRuleArgs args, @Nullable com.pulumi.resources.CustomResourceOptions options) {
if (options != null && options.getUrn().isPresent()) {
return null;
}
return args == null ? NetworkSecurityRuleArgs.Empty : args;
}
private static com.pulumi.resources.CustomResourceOptions makeResourceOptions(@Nullable com.pulumi.resources.CustomResourceOptions options, @Nullable Output id) {
var defaultOptions = com.pulumi.resources.CustomResourceOptions.builder()
.version(Utilities.getVersion())
.build();
return com.pulumi.resources.CustomResourceOptions.merge(defaultOptions, options, id);
}
/**
* Get an existing Host resource's state with the given name, ID, and optional extra
* properties used to qualify the lookup.
*
* @param name The _unique_ name of the resulting resource.
* @param id The _unique_ provider ID of the resource to lookup.
* @param state
* @param options Optional settings to control the behavior of the CustomResource.
*/
public static NetworkSecurityRule get(java.lang.String name, Output id, @Nullable NetworkSecurityRuleState state, @Nullable com.pulumi.resources.CustomResourceOptions options) {
return new NetworkSecurityRule(name, id, state, options);
}
}