Policy

Provides a resource to create an AWS Firewall Manager policy. You need to be using AWS organizations and have enabled the Firewall Manager administrator account.

Example Usage

using System.Collections.Generic;
using System.Text.Json;
using Pulumi;
using Aws = Pulumi.Aws;

class MyStack : Stack
{
    public MyStack()
    {
        var exampleRuleGroup = new Aws.WafRegional.RuleGroup("exampleRuleGroup", new Aws.WafRegional.RuleGroupArgs
        {
            MetricName = "WAFRuleGroupExample",
        });
        var examplePolicy = new Aws.Fms.Policy("examplePolicy", new Aws.Fms.PolicyArgs
        {
            ExcludeResourceTags = false,
            RemediationEnabled = false,
            ResourceTypeLists = 
            {
                "AWS::ElasticLoadBalancingV2::LoadBalancer",
            },
            SecurityServicePolicyData = new Aws.Fms.Inputs.PolicySecurityServicePolicyDataArgs
            {
                Type = "WAF",
                ManagedServiceData = exampleRuleGroup.Id.Apply(id => JsonSerializer.Serialize(new Dictionary<string, object?>
                {
                    { "type", "WAF" },
                    { "ruleGroups", new[]
                        {
                            new Dictionary<string, object?>
                            {
                                { "id", id },
                                { "overrideAction", new Dictionary<string, object?>
                                {
                                    { "type", "COUNT" },
                                } },
                            },
                        }
                     },
                    { "defaultAction", new Dictionary<string, object?>
                    {
                        { "type", "BLOCK" },
                    } },
                    { "overrideCustomerWebACLAssociation", false },
                })),
            },
        });
    }

}
package main

import (
	"encoding/json"

	"github.com/pulumi/pulumi-aws/sdk/v4/go/aws/fms"
	"github.com/pulumi/pulumi-aws/sdk/v4/go/aws/wafregional"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		exampleRuleGroup, err := wafregional.NewRuleGroup(ctx, "exampleRuleGroup", &wafregional.RuleGroupArgs{
			MetricName: pulumi.String("WAFRuleGroupExample"),
		})
		if err != nil {
			return err
		}
		_, err = fms.NewPolicy(ctx, "examplePolicy", &fms.PolicyArgs{
			ExcludeResourceTags: pulumi.Bool(false),
			RemediationEnabled:  pulumi.Bool(false),
			ResourceTypeLists: pulumi.StringArray{
				pulumi.String("AWS::ElasticLoadBalancingV2::LoadBalancer"),
			},
			SecurityServicePolicyData: &fms.PolicySecurityServicePolicyDataArgs{
				Type: pulumi.String("WAF"),
				ManagedServiceData: exampleRuleGroup.ID().ApplyT(func(id string) (pulumi.String, error) {
					var _zero pulumi.String
					tmpJSON0, err := json.Marshal(map[string]interface{}{
						"type": "WAF",
						"ruleGroups": []map[string]interface{}{
							map[string]interface{}{
								"id": id,
								"overrideAction": map[string]interface{}{
									"type": "COUNT",
								},
							},
						},
						"defaultAction": map[string]interface{}{
							"type": "BLOCK",
						},
						"overrideCustomerWebACLAssociation": false,
					})
					if err != nil {
						return _zero, err
					}
					json0 := string(tmpJSON0)
					return json0, nil
				}).(pulumi.StringOutput),
			},
		})
		if err != nil {
			return err
		}
		return nil
	})
}
import pulumi
import json
import pulumi_aws as aws

example_rule_group = aws.wafregional.RuleGroup("exampleRuleGroup", metric_name="WAFRuleGroupExample")
example_policy = aws.fms.Policy("examplePolicy",
    exclude_resource_tags=False,
    remediation_enabled=False,
    resource_type_lists=["AWS::ElasticLoadBalancingV2::LoadBalancer"],
    security_service_policy_data=aws.fms.PolicySecurityServicePolicyDataArgs(
        type="WAF",
        managed_service_data=example_rule_group.id.apply(lambda id: json.dumps({
            "type": "WAF",
            "ruleGroups": [{
                "id": id,
                "overrideAction": {
                    "type": "COUNT",
                },
            }],
            "defaultAction": {
                "type": "BLOCK",
            },
            "overrideCustomerWebACLAssociation": False,
        })),
    ))
import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";

const exampleRuleGroup = new aws.wafregional.RuleGroup("exampleRuleGroup", {metricName: "WAFRuleGroupExample"});
const examplePolicy = new aws.fms.Policy("examplePolicy", {
    excludeResourceTags: false,
    remediationEnabled: false,
    resourceTypeLists: ["AWS::ElasticLoadBalancingV2::LoadBalancer"],
    securityServicePolicyData: {
        type: "WAF",
        managedServiceData: exampleRuleGroup.id.apply(id => JSON.stringify({
            type: "WAF",
            ruleGroups: [{
                id: id,
                overrideAction: {
                    type: "COUNT",
                },
            }],
            defaultAction: {
                type: "BLOCK",
            },
            overrideCustomerWebACLAssociation: false,
        })),
    },
});

Create a Policy Resource

new Policy(name: string, args: PolicyArgs, opts?: CustomResourceOptions);
@overload
def Policy(resource_name: str,
           opts: Optional[ResourceOptions] = None,
           delete_all_policy_resources: Optional[bool] = None,
           exclude_map: Optional[PolicyExcludeMapArgs] = None,
           exclude_resource_tags: Optional[bool] = None,
           include_map: Optional[PolicyIncludeMapArgs] = None,
           name: Optional[str] = None,
           remediation_enabled: Optional[bool] = None,
           resource_tags: Optional[Mapping[str, str]] = None,
           resource_type: Optional[str] = None,
           resource_type_lists: Optional[Sequence[str]] = None,
           security_service_policy_data: Optional[PolicySecurityServicePolicyDataArgs] = None)
@overload
def Policy(resource_name: str,
           args: PolicyArgs,
           opts: Optional[ResourceOptions] = None)
func NewPolicy(ctx *Context, name string, args PolicyArgs, opts ...ResourceOption) (*Policy, error)
public Policy(string name, PolicyArgs args, CustomResourceOptions? opts = null)
name string
The unique name of the resource.
args PolicyArgs
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 PolicyArgs
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 PolicyArgs
The arguments to resource properties.
opts ResourceOption
Bag of options to control resource's behavior.
name string
The unique name of the resource.
args PolicyArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.

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

ExcludeResourceTags bool
A boolean value, if true the tags that are specified in the resource_tags are not protected by this policy. If set to false and resource_tags are populated, resources that contain tags will be protected by this policy.
SecurityServicePolicyData Pulumi.Aws.Fms.Inputs.PolicySecurityServicePolicyDataArgs
The objects to include in Security Service Policy Data. Documented below.
DeleteAllPolicyResources bool
If true, the request will also perform a clean-up process. Defaults to true. More information can be found here AWS Firewall Manager delete policy
ExcludeMap Pulumi.Aws.Fms.Inputs.PolicyExcludeMapArgs
A map of lists of accounts and OU’s to exclude from the policy.
IncludeMap Pulumi.Aws.Fms.Inputs.PolicyIncludeMapArgs
A map of lists of accounts and OU’s to include in the policy.
Name string
The friendly name of the AWS Firewall Manager Policy.
RemediationEnabled bool
A boolean value, indicates if the policy should automatically applied to resources that already exist in the account.
ResourceTags Dictionary<string, string>
A map of resource tags, that if present will filter protections on resources based on the exclude_resource_tags.
ResourceType string
A resource type to protect. Conflicts with resource_type_list. See the FMS API Reference for more information about supported values.
ResourceTypeLists List<string>
A list of resource types to protect. Conflicts with resource_type. See the FMS API Reference for more information about supported values.
ExcludeResourceTags bool
A boolean value, if true the tags that are specified in the resource_tags are not protected by this policy. If set to false and resource_tags are populated, resources that contain tags will be protected by this policy.
SecurityServicePolicyData PolicySecurityServicePolicyDataArgs
The objects to include in Security Service Policy Data. Documented below.
DeleteAllPolicyResources bool
If true, the request will also perform a clean-up process. Defaults to true. More information can be found here AWS Firewall Manager delete policy
ExcludeMap PolicyExcludeMapArgs
A map of lists of accounts and OU’s to exclude from the policy.
IncludeMap PolicyIncludeMapArgs
A map of lists of accounts and OU’s to include in the policy.
Name string
The friendly name of the AWS Firewall Manager Policy.
RemediationEnabled bool
A boolean value, indicates if the policy should automatically applied to resources that already exist in the account.
ResourceTags map[string]string
A map of resource tags, that if present will filter protections on resources based on the exclude_resource_tags.
ResourceType string
A resource type to protect. Conflicts with resource_type_list. See the FMS API Reference for more information about supported values.
ResourceTypeLists []string
A list of resource types to protect. Conflicts with resource_type. See the FMS API Reference for more information about supported values.
excludeResourceTags boolean
A boolean value, if true the tags that are specified in the resource_tags are not protected by this policy. If set to false and resource_tags are populated, resources that contain tags will be protected by this policy.
securityServicePolicyData PolicySecurityServicePolicyDataArgs
The objects to include in Security Service Policy Data. Documented below.
deleteAllPolicyResources boolean
If true, the request will also perform a clean-up process. Defaults to true. More information can be found here AWS Firewall Manager delete policy
excludeMap PolicyExcludeMapArgs
A map of lists of accounts and OU’s to exclude from the policy.
includeMap PolicyIncludeMapArgs
A map of lists of accounts and OU’s to include in the policy.
name string
The friendly name of the AWS Firewall Manager Policy.
remediationEnabled boolean
A boolean value, indicates if the policy should automatically applied to resources that already exist in the account.
resourceTags {[key: string]: string}
A map of resource tags, that if present will filter protections on resources based on the exclude_resource_tags.
resourceType string
A resource type to protect. Conflicts with resource_type_list. See the FMS API Reference for more information about supported values.
resourceTypeLists string[]
A list of resource types to protect. Conflicts with resource_type. See the FMS API Reference for more information about supported values.
exclude_resource_tags bool
A boolean value, if true the tags that are specified in the resource_tags are not protected by this policy. If set to false and resource_tags are populated, resources that contain tags will be protected by this policy.
security_service_policy_data PolicySecurityServicePolicyDataArgs
The objects to include in Security Service Policy Data. Documented below.
delete_all_policy_resources bool
If true, the request will also perform a clean-up process. Defaults to true. More information can be found here AWS Firewall Manager delete policy
exclude_map PolicyExcludeMapArgs
A map of lists of accounts and OU’s to exclude from the policy.
include_map PolicyIncludeMapArgs
A map of lists of accounts and OU’s to include in the policy.
name str
The friendly name of the AWS Firewall Manager Policy.
remediation_enabled bool
A boolean value, indicates if the policy should automatically applied to resources that already exist in the account.
resource_tags Mapping[str, str]
A map of resource tags, that if present will filter protections on resources based on the exclude_resource_tags.
resource_type str
A resource type to protect. Conflicts with resource_type_list. See the FMS API Reference for more information about supported values.
resource_type_lists Sequence[str]
A list of resource types to protect. Conflicts with resource_type. See the FMS API Reference for more information about supported values.

Outputs

All input properties are implicitly available as output properties. Additionally, the Policy resource produces the following output properties:

Arn string
Id string
The provider-assigned unique ID for this managed resource.
PolicyUpdateToken string
A unique identifier for each update to the policy.
Arn string
Id string
The provider-assigned unique ID for this managed resource.
PolicyUpdateToken string
A unique identifier for each update to the policy.
arn string
id string
The provider-assigned unique ID for this managed resource.
policyUpdateToken string
A unique identifier for each update to the policy.
arn str
id str
The provider-assigned unique ID for this managed resource.
policy_update_token str
A unique identifier for each update to the policy.

Look up an Existing Policy Resource

Get an existing Policy 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?: PolicyState, opts?: CustomResourceOptions): Policy
@staticmethod
def get(resource_name: str,
        id: str,
        opts: Optional[ResourceOptions] = None,
        arn: Optional[str] = None,
        delete_all_policy_resources: Optional[bool] = None,
        exclude_map: Optional[PolicyExcludeMapArgs] = None,
        exclude_resource_tags: Optional[bool] = None,
        include_map: Optional[PolicyIncludeMapArgs] = None,
        name: Optional[str] = None,
        policy_update_token: Optional[str] = None,
        remediation_enabled: Optional[bool] = None,
        resource_tags: Optional[Mapping[str, str]] = None,
        resource_type: Optional[str] = None,
        resource_type_lists: Optional[Sequence[str]] = None,
        security_service_policy_data: Optional[PolicySecurityServicePolicyDataArgs] = None) -> Policy
func GetPolicy(ctx *Context, name string, id IDInput, state *PolicyState, opts ...ResourceOption) (*Policy, error)
public static Policy Get(string name, Input<string> id, PolicyState? state, CustomResourceOptions? opts = null)
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.

The following state arguments are supported:

Arn string
DeleteAllPolicyResources bool
If true, the request will also perform a clean-up process. Defaults to true. More information can be found here AWS Firewall Manager delete policy
ExcludeMap Pulumi.Aws.Fms.Inputs.PolicyExcludeMapArgs
A map of lists of accounts and OU’s to exclude from the policy.
ExcludeResourceTags bool
A boolean value, if true the tags that are specified in the resource_tags are not protected by this policy. If set to false and resource_tags are populated, resources that contain tags will be protected by this policy.
IncludeMap Pulumi.Aws.Fms.Inputs.PolicyIncludeMapArgs
A map of lists of accounts and OU’s to include in the policy.
Name string
The friendly name of the AWS Firewall Manager Policy.
PolicyUpdateToken string
A unique identifier for each update to the policy.
RemediationEnabled bool
A boolean value, indicates if the policy should automatically applied to resources that already exist in the account.
ResourceTags Dictionary<string, string>
A map of resource tags, that if present will filter protections on resources based on the exclude_resource_tags.
ResourceType string
A resource type to protect. Conflicts with resource_type_list. See the FMS API Reference for more information about supported values.
ResourceTypeLists List<string>
A list of resource types to protect. Conflicts with resource_type. See the FMS API Reference for more information about supported values.
SecurityServicePolicyData Pulumi.Aws.Fms.Inputs.PolicySecurityServicePolicyDataArgs
The objects to include in Security Service Policy Data. Documented below.
Arn string
DeleteAllPolicyResources bool
If true, the request will also perform a clean-up process. Defaults to true. More information can be found here AWS Firewall Manager delete policy
ExcludeMap PolicyExcludeMapArgs
A map of lists of accounts and OU’s to exclude from the policy.
ExcludeResourceTags bool
A boolean value, if true the tags that are specified in the resource_tags are not protected by this policy. If set to false and resource_tags are populated, resources that contain tags will be protected by this policy.
IncludeMap PolicyIncludeMapArgs
A map of lists of accounts and OU’s to include in the policy.
Name string
The friendly name of the AWS Firewall Manager Policy.
PolicyUpdateToken string
A unique identifier for each update to the policy.
RemediationEnabled bool
A boolean value, indicates if the policy should automatically applied to resources that already exist in the account.
ResourceTags map[string]string
A map of resource tags, that if present will filter protections on resources based on the exclude_resource_tags.
ResourceType string
A resource type to protect. Conflicts with resource_type_list. See the FMS API Reference for more information about supported values.
ResourceTypeLists []string
A list of resource types to protect. Conflicts with resource_type. See the FMS API Reference for more information about supported values.
SecurityServicePolicyData PolicySecurityServicePolicyDataArgs
The objects to include in Security Service Policy Data. Documented below.
arn string
deleteAllPolicyResources boolean
If true, the request will also perform a clean-up process. Defaults to true. More information can be found here AWS Firewall Manager delete policy
excludeMap PolicyExcludeMapArgs
A map of lists of accounts and OU’s to exclude from the policy.
excludeResourceTags boolean
A boolean value, if true the tags that are specified in the resource_tags are not protected by this policy. If set to false and resource_tags are populated, resources that contain tags will be protected by this policy.
includeMap PolicyIncludeMapArgs
A map of lists of accounts and OU’s to include in the policy.
name string
The friendly name of the AWS Firewall Manager Policy.
policyUpdateToken string
A unique identifier for each update to the policy.
remediationEnabled boolean
A boolean value, indicates if the policy should automatically applied to resources that already exist in the account.
resourceTags {[key: string]: string}
A map of resource tags, that if present will filter protections on resources based on the exclude_resource_tags.
resourceType string
A resource type to protect. Conflicts with resource_type_list. See the FMS API Reference for more information about supported values.
resourceTypeLists string[]
A list of resource types to protect. Conflicts with resource_type. See the FMS API Reference for more information about supported values.
securityServicePolicyData PolicySecurityServicePolicyDataArgs
The objects to include in Security Service Policy Data. Documented below.
arn str
delete_all_policy_resources bool
If true, the request will also perform a clean-up process. Defaults to true. More information can be found here AWS Firewall Manager delete policy
exclude_map PolicyExcludeMapArgs
A map of lists of accounts and OU’s to exclude from the policy.
exclude_resource_tags bool
A boolean value, if true the tags that are specified in the resource_tags are not protected by this policy. If set to false and resource_tags are populated, resources that contain tags will be protected by this policy.
include_map PolicyIncludeMapArgs
A map of lists of accounts and OU’s to include in the policy.
name str
The friendly name of the AWS Firewall Manager Policy.
policy_update_token str
A unique identifier for each update to the policy.
remediation_enabled bool
A boolean value, indicates if the policy should automatically applied to resources that already exist in the account.
resource_tags Mapping[str, str]
A map of resource tags, that if present will filter protections on resources based on the exclude_resource_tags.
resource_type str
A resource type to protect. Conflicts with resource_type_list. See the FMS API Reference for more information about supported values.
resource_type_lists Sequence[str]
A list of resource types to protect. Conflicts with resource_type. See the FMS API Reference for more information about supported values.
security_service_policy_data PolicySecurityServicePolicyDataArgs
The objects to include in Security Service Policy Data. Documented below.

Supporting Types

PolicyExcludeMap

Accounts List<string>
A list of AWS Organization member Accounts that you want to include for this AWS FMS Policy.
Orgunits List<string>
A list of AWS Organizational Units that you want to include for this AWS FMS Policy. Specifying an OU is the equivalent of specifying all accounts in the OU and in any of its child OUs, including any child OUs and accounts that are added at a later time.
Accounts []string
A list of AWS Organization member Accounts that you want to include for this AWS FMS Policy.
Orgunits []string
A list of AWS Organizational Units that you want to include for this AWS FMS Policy. Specifying an OU is the equivalent of specifying all accounts in the OU and in any of its child OUs, including any child OUs and accounts that are added at a later time.
accounts string[]
A list of AWS Organization member Accounts that you want to include for this AWS FMS Policy.
orgunits string[]
A list of AWS Organizational Units that you want to include for this AWS FMS Policy. Specifying an OU is the equivalent of specifying all accounts in the OU and in any of its child OUs, including any child OUs and accounts that are added at a later time.
accounts Sequence[str]
A list of AWS Organization member Accounts that you want to include for this AWS FMS Policy.
orgunits Sequence[str]
A list of AWS Organizational Units that you want to include for this AWS FMS Policy. Specifying an OU is the equivalent of specifying all accounts in the OU and in any of its child OUs, including any child OUs and accounts that are added at a later time.

PolicyIncludeMap

Accounts List<string>
A list of AWS Organization member Accounts that you want to include for this AWS FMS Policy.
Orgunits List<string>
A list of AWS Organizational Units that you want to include for this AWS FMS Policy. Specifying an OU is the equivalent of specifying all accounts in the OU and in any of its child OUs, including any child OUs and accounts that are added at a later time.
Accounts []string
A list of AWS Organization member Accounts that you want to include for this AWS FMS Policy.
Orgunits []string
A list of AWS Organizational Units that you want to include for this AWS FMS Policy. Specifying an OU is the equivalent of specifying all accounts in the OU and in any of its child OUs, including any child OUs and accounts that are added at a later time.
accounts string[]
A list of AWS Organization member Accounts that you want to include for this AWS FMS Policy.
orgunits string[]
A list of AWS Organizational Units that you want to include for this AWS FMS Policy. Specifying an OU is the equivalent of specifying all accounts in the OU and in any of its child OUs, including any child OUs and accounts that are added at a later time.
accounts Sequence[str]
A list of AWS Organization member Accounts that you want to include for this AWS FMS Policy.
orgunits Sequence[str]
A list of AWS Organizational Units that you want to include for this AWS FMS Policy. Specifying an OU is the equivalent of specifying all accounts in the OU and in any of its child OUs, including any child OUs and accounts that are added at a later time.

PolicySecurityServicePolicyData

Type string
The service that the policy is using to protect the resources. For the current list of supported types, please refer to the AWS Firewall Manager SecurityServicePolicyData API Type Reference.
ManagedServiceData string
Details about the service that are specific to the service type, in JSON format. For service type SHIELD_ADVANCED, this is an empty string. Examples depending on type can be found in the AWS Firewall Manager SecurityServicePolicyData API Reference.
Type string
The service that the policy is using to protect the resources. For the current list of supported types, please refer to the AWS Firewall Manager SecurityServicePolicyData API Type Reference.
ManagedServiceData string
Details about the service that are specific to the service type, in JSON format. For service type SHIELD_ADVANCED, this is an empty string. Examples depending on type can be found in the AWS Firewall Manager SecurityServicePolicyData API Reference.
type string
The service that the policy is using to protect the resources. For the current list of supported types, please refer to the AWS Firewall Manager SecurityServicePolicyData API Type Reference.
managedServiceData string
Details about the service that are specific to the service type, in JSON format. For service type SHIELD_ADVANCED, this is an empty string. Examples depending on type can be found in the AWS Firewall Manager SecurityServicePolicyData API Reference.
type str
The service that the policy is using to protect the resources. For the current list of supported types, please refer to the AWS Firewall Manager SecurityServicePolicyData API Type Reference.
managed_service_data str
Details about the service that are specific to the service type, in JSON format. For service type SHIELD_ADVANCED, this is an empty string. Examples depending on type can be found in the AWS Firewall Manager SecurityServicePolicyData API Reference.

Import

Firewall Manager policies can be imported using the policy ID, e.g.,

 $ pulumi import aws:fms/policy:Policy example 5be49585-a7e3-4c49-dde1-a179fe4a619a

Package Details

Repository
https://github.com/pulumi/pulumi-aws
License
Apache-2.0
Notes
This Pulumi package is based on the aws Terraform Provider.