Policy class

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.

> NOTE: Due to limitations with testing, we provide it as best effort. If you find it useful, and have the ability to help test or notice issues, consider reaching out to us on GitHub.

Example Usage

import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";

const exampleRuleGroup = new aws.wafregional.RuleGroup("example", {
    metricName: "WAFRuleGroupExample",
    name: "WAF-Rule-Group-Example",
});
const example = new aws.fms.Policy("example", {
    securityServicePolicyData: {
        type: "WAF",
        managedServiceData: pulumi.jsonStringify({
            type: "WAF",
            ruleGroups: [{
                id: exampleRuleGroup.id,
                overrideAction: {
                    type: "COUNT",
                },
            }],
            defaultAction: {
                type: "BLOCK",
            },
            overrideCustomerWebACLAssociation: false,
        }),
    },
    name: "FMS-Policy-Example",
    excludeResourceTags: false,
    remediationEnabled: false,
    resourceType: "AWS::ElasticLoadBalancingV2::LoadBalancer",
    tags: {
        Name: "example-fms-policy",
    },
});
import pulumi
import json
import pulumi_aws as aws

example_rule_group = aws.wafregional.RuleGroup("example",
    metric_name="WAFRuleGroupExample",
    name="WAF-Rule-Group-Example")
example = aws.fms.Policy("example",
    security_service_policy_data={
        "type": "WAF",
        "managed_service_data": pulumi.Output.json_dumps({
            "type": "WAF",
            "ruleGroups": [{
                "id": example_rule_group.id,
                "overrideAction": {
                    "type": "COUNT",
                },
            }],
            "defaultAction": {
                "type": "BLOCK",
            },
            "overrideCustomerWebACLAssociation": False,
        }),
    },
    name="FMS-Policy-Example",
    exclude_resource_tags=False,
    remediation_enabled=False,
    resource_type="AWS::ElasticLoadBalancingV2::LoadBalancer",
    tags={
        "Name": "example-fms-policy",
    })
using System.Collections.Generic;
using System.Linq;
using System.Text.Json;
using Pulumi;
using Aws = Pulumi.Aws;

return await Deployment.RunAsync(() =>
{
    var exampleRuleGroup = new Aws.WafRegional.RuleGroup("example", new()
    {
        MetricName = "WAFRuleGroupExample",
        Name = "WAF-Rule-Group-Example",
    });

    var example = new Aws.Fms.Policy("example", new()
    {
        SecurityServicePolicyData = new Aws.Fms.Inputs.PolicySecurityServicePolicyDataArgs
        {
            Type = "WAF",
            ManagedServiceData = Output.JsonSerialize(Output.Create(new Dictionary<string, object?>
            {
                ["type"] = "WAF",
                ["ruleGroups"] = new[]
                {
                    new Dictionary<string, object?>
                    {
                        ["id"] = exampleRuleGroup.Id,
                        ["overrideAction"] = new Dictionary<string, object?>
                        {
                            ["type"] = "COUNT",
                        },
                    },
                },
                ["defaultAction"] = new Dictionary<string, object?>
                {
                    ["type"] = "BLOCK",
                },
                ["overrideCustomerWebACLAssociation"] = false,
            })),
        },
        Name = "FMS-Policy-Example",
        ExcludeResourceTags = false,
        RemediationEnabled = false,
        ResourceType = "AWS::ElasticLoadBalancingV2::LoadBalancer",
        Tags =
        {
            { "Name", "example-fms-policy" },
        },
    });

});
package main

import (
	"encoding/json"

	"github.com/pulumi/pulumi-aws/sdk/v7/go/aws/fms"
	"github.com/pulumi/pulumi-aws/sdk/v7/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, "example", &wafregional.RuleGroupArgs{
			MetricName: pulumi.String("WAFRuleGroupExample"),
			Name:       pulumi.String("WAF-Rule-Group-Example"),
		})
		if err != nil {
			return err
		}
		_, err = fms.NewPolicy(ctx, "example", &fms.PolicyArgs{
			SecurityServicePolicyData: &fms.PolicySecurityServicePolicyDataArgs{
				Type: pulumi.String("WAF"),
				ManagedServiceData: exampleRuleGroup.ID().ApplyT(func(id pulumi.ID) (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]string{
									"type": "COUNT",
								},
							},
						},
						"defaultAction": map[string]string{
							"type": "BLOCK",
						},
						"overrideCustomerWebACLAssociation": false,
					})
					if err != nil {
						return _zero, err
					}
					json0 := string(tmpJSON0)
					return pulumi.String(json0), nil
				}).(pulumi.StringOutput),
			},
			Name:                pulumi.String("FMS-Policy-Example"),
			ExcludeResourceTags: pulumi.Bool(false),
			RemediationEnabled:  pulumi.Bool(false),
			ResourceType:        pulumi.String("AWS::ElasticLoadBalancingV2::LoadBalancer"),
			Tags: pulumi.StringMap{
				"Name": pulumi.String("example-fms-policy"),
			},
		})
		if err != nil {
			return err
		}
		return nil
	})
}
pulumi {
  required_providers {
    aws = {
      source = "pulumi/aws"
    }
  }
}

resource "aws_fms_policy" "example" {
  security_service_policy_data = {
    type = "WAF"
    managed_service_data = jsonencode({
      "type" = "WAF"
      "ruleGroups" = [{
        "id" = aws_wafregional_rulegroup.example.id
        "overrideAction" = {
          "type" = "COUNT"
        }
      }]
      "defaultAction" = {
        "type" = "BLOCK"
      }
      "overrideCustomerWebACLAssociation" = false
    })
  }
  name                  = "FMS-Policy-Example"
  exclude_resource_tags = false
  remediation_enabled   = false
  resource_type         = "AWS::ElasticLoadBalancingV2::LoadBalancer"
  tags = {
    "Name" = "example-fms-policy"
  }
}
resource "aws_wafregional_rulegroup" "example" {
  metric_name = "WAFRuleGroupExample"
  name        = "WAF-Rule-Group-Example"
}
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.aws.wafregional.RuleGroup;
import com.pulumi.aws.wafregional.RuleGroupArgs;
import com.pulumi.aws.fms.Policy;
import com.pulumi.aws.fms.PolicyArgs;
import com.pulumi.aws.fms.inputs.PolicySecurityServicePolicyDataArgs;
import static com.pulumi.codegen.internal.Serialization.*;
import java.util.ArrayList;
import java.util.Arrays;
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 exampleRuleGroup = new RuleGroup("exampleRuleGroup", RuleGroupArgs.builder()
            .metricName("WAFRuleGroupExample")
            .name("WAF-Rule-Group-Example")
            .build());

        var example = new Policy("example", PolicyArgs.builder()
            .securityServicePolicyData(PolicySecurityServicePolicyDataArgs.builder()
                .type("WAF")
                .managedServiceData(exampleRuleGroup.id().applyValue(_id -> serializeJson(
                    jsonObject(
                        jsonProperty("type", "WAF"),
                        jsonProperty("ruleGroups", jsonArray(jsonObject(
                            jsonProperty("id", _id),
                            jsonProperty("overrideAction", jsonObject(
                                jsonProperty("type", "COUNT")
                            ))
                        ))),
                        jsonProperty("defaultAction", jsonObject(
                            jsonProperty("type", "BLOCK")
                        )),
                        jsonProperty("overrideCustomerWebACLAssociation", false)
                    ))))
                .build())
            .name("FMS-Policy-Example")
            .excludeResourceTags(false)
            .remediationEnabled(false)
            .resourceType("AWS::ElasticLoadBalancingV2::LoadBalancer")
            .tags(Map.of("Name", "example-fms-policy"))
            .build());

    }
}
resources:
  example:
    type: aws:fms:Policy
    properties:
      securityServicePolicyData:
        type: WAF
        managedServiceData:
          fn::toJSON:
            type: WAF
            ruleGroups:
              - id: ${exampleRuleGroup.id}
                overrideAction:
                  type: COUNT
            defaultAction:
              type: BLOCK
            overrideCustomerWebACLAssociation: false
      name: FMS-Policy-Example
      excludeResourceTags: false
      remediationEnabled: false
      resourceType: AWS::ElasticLoadBalancingV2::LoadBalancer
      tags:
        Name: example-fms-policy
  exampleRuleGroup:
    type: aws:wafregional:RuleGroup
    name: example
    properties:
      metricName: WAFRuleGroupExample
      name: WAF-Rule-Group-Example

Import

Using pulumi import, import Firewall Manager policies using the policy ID. For example:

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

Constructors

Policy(String name, {PolicyArgs? args, CustomResourceOptions? options})
Creates a new Policy. name The Pulumi resource name. args Arguments used to configure this Policy. The set of arguments for Policy. options Resource options controlling this resource's behavior.
Policy.reference(String urn)
Creates a typed reference to an existing Policy resource.

Properties

arn ↔ Output<String>
ARN of the policy.
latefinal
childResources → Set<Resource>
finalinherited
completionSources ↔ Map<String, IOutputCompletionSource>
latefinalinherited
deleteAllPolicyResources ↔ Output<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
latefinal
deleteUnusedFmManagedResources ↔ Output<bool?>
If true, Firewall Manager will automatically remove protections from resources that leave the policy scope. Defaults to false. More information can be found here AWS Firewall Manager policy contents
latefinal
description ↔ Output<String?>
Description of the AWS Network Firewall firewall policy.
latefinal
excludeMap ↔ Output<PolicyExcludeMap?>
Map of lists of accounts and OUs to exclude from the policy. See the excludeMap block.
latefinal
excludeResourceTags ↔ Output<bool>
Whether resources with the tags specified in resourceTags are excluded from protection. If true, tagged resources are not protected by this policy. If false and resourceTags are populated, resources that contain those tags are protected by this policy.
latefinal
hashCode → int
The hash code for this object.
no setterinherited
id ↔ Output<String>
getter/setter pairinherited
includeMap ↔ Output<PolicyIncludeMap?>
Map of lists of accounts and OUs to include in the policy. See the includeMap block.
latefinal
isCustom → bool
Returns whether this resource is provider-managed.
no setterinherited
isProtected → bool
Returns whether this resource is protected from deletion.
no setterinherited
isRemote → bool
Whether this resource is registered as remote.
no setterinherited
isResourceReference → bool
Whether this instance represents a resource value returned over RPC.
finalinherited
name ↔ Output<String>
Friendly name of the AWS Firewall Manager Policy.
latefinal
policyUpdateToken ↔ Output<String>
Unique identifier for each update to the policy.
latefinal
region ↔ Output<String>
Region where this resource will be managed. Defaults to the Region set in the provider configuration.
latefinal
remediationEnabled ↔ Output<bool?>
Whether the policy is automatically applied to resources that already exist in the account.
latefinal
resourceSetIds ↔ Output<List<String>>
Set of resource set IDs associated with the policy.
latefinal
resourceTagLogicalOperator ↔ Output<String>
Controls how multiple resource tags are combined: with AND, so that a resource must have all tags to be included or excluded, or OR, so that a resource must have at least one tag. The valid values are AND and OR.
latefinal
resourceTags ↔ Output<Map<String, String>?>
Map of resource tags that, if present, filter protections on resources based on excludeResourceTags.
latefinal
resourceTransforms → List<ResourceTransform>
Inherited/explicit async transforms.
no setterinherited
resourceType ↔ Output<String>
Resource type to protect. Conflicts with resourceTypeList. See the FMS API Reference for more information about supported values.
latefinal
resourceTypeLists ↔ Output<List<String>>
List of resource types to protect. Conflicts with resourceType. See the FMS API Reference for more information about supported values. Lists with only one element are not supported, instead use resourceType.
latefinal
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
securityServicePolicyData ↔ Output<PolicySecurityServicePolicyData>
Objects to include in Security Service Policy Data. See the securityServicePolicyData block.
latefinal
tags ↔ Output<Map<String, String>?>
Key-value mapping of resource tags. If configured with a provider defaultTags configuration block present, tags with matching keys will overwrite those defined at the provider-level
latefinal
tagsAll ↔ Output<Map<String, String>>
Map of tags assigned to the resource, including those inherited from the provider defaultTags configuration block.
latefinal
transformations → List<ResourceTransformation>
Inherited/explicit legacy transformations.
no setterinherited
urn ↔ Output<String>
latefinalinherited

Methods

failId(Object error) → void
Completes this resource ID with an error when registration fails.
inherited
failOutputs(Object error) → void
Completes all output properties with error.
inherited
failUrn(Object error) → void
Completes this resource URN with an error when registration fails.
inherited
getProvider(String moduleMember) → ProviderResource?
Returns provider for moduleMember's package, if configured.
inherited
getResourceName() → String
Returns this resource's logical name.
inherited
getResourceType() → String
Returns this resource's Pulumi type token.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
registerOutput<T>(String propertyName, {Object? decoder(Object?)?, bool isSecret = false}) → Output<T>
Registers a dynamic output property for this resource.
inherited
resolveId(String? value, {required bool isKnown}) → void
Resolves the provider-assigned ID for this resource.
inherited
resolveOutputs(Struct outputs) → void
Resolves all output properties from a monitor response payload.
inherited
resolveUrn(String value) → void
Resolves this resource's URN once assigned by the engine.
inherited
serializeProperties(Map<String, dynamic> properties) → Future<Struct>
Serializes resource properties for RPC transmission.
inherited
toString() → String
A string representation of this object.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited

Static Methods

get(String name, Input<String> id, {PolicyState? state, CustomResourceOptions? options}) → Policy
Gets an existing Policy resource's state with the given name and id.