// *** 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.SubnetNetworkSecurityGroupAssociationArgs;
import com.pulumi.azure.network.inputs.SubnetNetworkSecurityGroupAssociationState;
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.String;
import javax.annotation.Nullable;

/**
 * Associates a Network Security Group with a Subnet within a Virtual Network.
 * 
 * ## Example Usage
 * ```java
 * 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.VirtualNetwork;
 * import com.pulumi.azure.network.VirtualNetworkArgs;
 * import com.pulumi.azure.network.Subnet;
 * import com.pulumi.azure.network.SubnetArgs;
 * import com.pulumi.azure.network.NetworkSecurityGroup;
 * import com.pulumi.azure.network.NetworkSecurityGroupArgs;
 * import com.pulumi.azure.network.inputs.NetworkSecurityGroupSecurityRuleArgs;
 * import com.pulumi.azure.network.SubnetNetworkSecurityGroupAssociation;
 * import com.pulumi.azure.network.SubnetNetworkSecurityGroupAssociationArgs;
 * 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 exampleResourceGroup = new ResourceGroup(&#34;exampleResourceGroup&#34;, ResourceGroupArgs.builder()        
 *             .location(&#34;West Europe&#34;)
 *             .build());
 * 
 *         var exampleVirtualNetwork = new VirtualNetwork(&#34;exampleVirtualNetwork&#34;, VirtualNetworkArgs.builder()        
 *             .addressSpaces(&#34;10.0.0.0/16&#34;)
 *             .location(exampleResourceGroup.location())
 *             .resourceGroupName(exampleResourceGroup.name())
 *             .build());
 * 
 *         var exampleSubnet = new Subnet(&#34;exampleSubnet&#34;, SubnetArgs.builder()        
 *             .resourceGroupName(exampleResourceGroup.name())
 *             .virtualNetworkName(exampleVirtualNetwork.name())
 *             .addressPrefixes(&#34;10.0.2.0/24&#34;)
 *             .build());
 * 
 *         var exampleNetworkSecurityGroup = new NetworkSecurityGroup(&#34;exampleNetworkSecurityGroup&#34;, NetworkSecurityGroupArgs.builder()        
 *             .location(exampleResourceGroup.location())
 *             .resourceGroupName(exampleResourceGroup.name())
 *             .securityRules(NetworkSecurityGroupSecurityRuleArgs.builder()
 *                 .name(&#34;test123&#34;)
 *                 .priority(100)
 *                 .direction(&#34;Inbound&#34;)
 *                 .access(&#34;Allow&#34;)
 *                 .protocol(&#34;Tcp&#34;)
 *                 .sourcePortRange(&#34;*&#34;)
 *                 .destinationPortRange(&#34;*&#34;)
 *                 .sourceAddressPrefix(&#34;*&#34;)
 *                 .destinationAddressPrefix(&#34;*&#34;)
 *                 .build())
 *             .build());
 * 
 *         var exampleSubnetNetworkSecurityGroupAssociation = new SubnetNetworkSecurityGroupAssociation(&#34;exampleSubnetNetworkSecurityGroupAssociation&#34;, SubnetNetworkSecurityGroupAssociationArgs.builder()        
 *             .subnetId(exampleSubnet.id())
 *             .networkSecurityGroupId(exampleNetworkSecurityGroup.id())
 *             .build());
 * 
 *     }
 * }
 * ```
 * 
 * ## Import
 * 
 * Subnet `&lt;-&gt;` Network Security Group Associations can be imported using the `resource id` of the Subnet, e.g.
 * 
 * ```sh
 *  $ pulumi import azure:network/subnetNetworkSecurityGroupAssociation:SubnetNetworkSecurityGroupAssociation association1 /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/mygroup1/providers/Microsoft.Network/virtualNetworks/myvnet1/subnets/mysubnet1
 * ```
 * 
 */
@ResourceType(type="azure:network/subnetNetworkSecurityGroupAssociation:SubnetNetworkSecurityGroupAssociation")
public class SubnetNetworkSecurityGroupAssociation extends com.pulumi.resources.CustomResource {
    /**
     * The ID of the Network Security Group which should be associated with the Subnet. Changing this forces a new resource to be created.
     * 
     */
    @Export(name="networkSecurityGroupId", refs={String.class}, tree="[0]")
    private Output<String> networkSecurityGroupId;

    /**
     * @return The ID of the Network Security Group which should be associated with the Subnet. Changing this forces a new resource to be created.
     * 
     */
    public Output<String> networkSecurityGroupId() {
        return this.networkSecurityGroupId;
    }
    /**
     * The ID of the Subnet. Changing this forces a new resource to be created.
     * 
     */
    @Export(name="subnetId", refs={String.class}, tree="[0]")
    private Output<String> subnetId;

    /**
     * @return The ID of the Subnet. Changing this forces a new resource to be created.
     * 
     */
    public Output<String> subnetId() {
        return this.subnetId;
    }

    /**
     *
     * @param name The _unique_ name of the resulting resource.
     */
    public SubnetNetworkSecurityGroupAssociation(String name) {
        this(name, SubnetNetworkSecurityGroupAssociationArgs.Empty);
    }
    /**
     *
     * @param name The _unique_ name of the resulting resource.
     * @param args The arguments to use to populate this resource's properties.
     */
    public SubnetNetworkSecurityGroupAssociation(String name, SubnetNetworkSecurityGroupAssociationArgs 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 SubnetNetworkSecurityGroupAssociation(String name, SubnetNetworkSecurityGroupAssociationArgs args, @Nullable com.pulumi.resources.CustomResourceOptions options) {
        super("azure:network/subnetNetworkSecurityGroupAssociation:SubnetNetworkSecurityGroupAssociation", name, args == null ? SubnetNetworkSecurityGroupAssociationArgs.Empty : args, makeResourceOptions(options, Codegen.empty()));
    }

    private SubnetNetworkSecurityGroupAssociation(String name, Output<String> id, @Nullable SubnetNetworkSecurityGroupAssociationState state, @Nullable com.pulumi.resources.CustomResourceOptions options) {
        super("azure:network/subnetNetworkSecurityGroupAssociation:SubnetNetworkSecurityGroupAssociation", name, state, makeResourceOptions(options, id));
    }

    private static com.pulumi.resources.CustomResourceOptions makeResourceOptions(@Nullable com.pulumi.resources.CustomResourceOptions options, @Nullable Output<String> 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 SubnetNetworkSecurityGroupAssociation get(String name, Output<String> id, @Nullable SubnetNetworkSecurityGroupAssociationState state, @Nullable com.pulumi.resources.CustomResourceOptions options) {
        return new SubnetNetworkSecurityGroupAssociation(name, id, state, options);
    }
}
