OrganizationCustomRule class

Manages a Config Organization Custom Rule. More information about these rules can be found in the Enabling AWS Config Rules Across all Accounts in Your Organization and AWS Config Managed Rules documentation. For working with Organization Managed Rules (those invoking an AWS managed rule), see the aws.cfg.OrganizationManagedRule resource.

> NOTE: This resource must be created in the Organization master account and rules will include the master account unless its ID is added to the excludedAccounts argument.

> NOTE: The proper Lambda permission to allow the AWS Config service invoke the Lambda Function must be in place before the rule will successfully create or update. See also the aws.lambda.Permission resource.

Example Usage

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

const example = new aws.lambda.Permission("example", {
    action: "lambda:InvokeFunction",
    "function": exampleAwsLambdaFunction.arn,
    principal: "config.amazonaws.com",
    statementId: "AllowExecutionFromConfig",
});
const exampleOrganization = new aws.organizations.Organization("example", {
    awsServiceAccessPrincipals: ["config-multiaccountsetup.amazonaws.com"],
    featureSet: "ALL",
});
const exampleOrganizationCustomRule = new aws.cfg.OrganizationCustomRule("example", {
    lambdaFunctionArn: exampleAwsLambdaFunction.arn,
    name: "example",
    triggerTypes: ["ConfigurationItemChangeNotification"],
}, {
    dependsOn: [
        example,
        exampleOrganization,
    ],
});
import pulumi
import pulumi_aws as aws

example = aws.lambda_.Permission("example",
    action="lambda:InvokeFunction",
    function=example_aws_lambda_function["arn"],
    principal="config.amazonaws.com",
    statement_id="AllowExecutionFromConfig")
example_organization = aws.organizations.Organization("example",
    aws_service_access_principals=["config-multiaccountsetup.amazonaws.com"],
    feature_set="ALL")
example_organization_custom_rule = aws.cfg.OrganizationCustomRule("example",
    lambda_function_arn=example_aws_lambda_function["arn"],
    name="example",
    trigger_types=["ConfigurationItemChangeNotification"],
    opts = pulumi.ResourceOptions(depends_on=[
            example,
            example_organization,
        ]))
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Aws = Pulumi.Aws;

return await Deployment.RunAsync(() =>
{
    var example = new Aws.Lambda.Permission("example", new()
    {
        Action = "lambda:InvokeFunction",
        Function = exampleAwsLambdaFunction.Arn,
        Principal = "config.amazonaws.com",
        StatementId = "AllowExecutionFromConfig",
    });

    var exampleOrganization = new Aws.Organizations.Organization("example", new()
    {
        AwsServiceAccessPrincipals = new[]
        {
            "config-multiaccountsetup.amazonaws.com",
        },
        FeatureSet = "ALL",
    });

    var exampleOrganizationCustomRule = new Aws.Cfg.OrganizationCustomRule("example", new()
    {
        LambdaFunctionArn = exampleAwsLambdaFunction.Arn,
        Name = "example",
        TriggerTypes = new[]
        {
            "ConfigurationItemChangeNotification",
        },
    }, new CustomResourceOptions
    {
        DependsOn =
        {
            example,
            exampleOrganization,
        },
    });

});
package main

import (
	"github.com/pulumi/pulumi-aws/sdk/v7/go/aws/cfg"
	"github.com/pulumi/pulumi-aws/sdk/v7/go/aws/lambda"
	"github.com/pulumi/pulumi-aws/sdk/v7/go/aws/organizations"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		example, err := lambda.NewPermission(ctx, "example", &lambda.PermissionArgs{
			Action:      pulumi.String("lambda:InvokeFunction"),
			Function:    pulumi.Any(exampleAwsLambdaFunction.Arn),
			Principal:   pulumi.String("config.amazonaws.com"),
			StatementId: pulumi.String("AllowExecutionFromConfig"),
		})
		if err != nil {
			return err
		}
		exampleOrganization, err := organizations.NewOrganization(ctx, "example", &organizations.OrganizationArgs{
			AwsServiceAccessPrincipals: pulumi.StringArray{
				pulumi.String("config-multiaccountsetup.amazonaws.com"),
			},
			FeatureSet: pulumi.String("ALL"),
		})
		if err != nil {
			return err
		}
		_, err = cfg.NewOrganizationCustomRule(ctx, "example", &cfg.OrganizationCustomRuleArgs{
			LambdaFunctionArn: pulumi.Any(exampleAwsLambdaFunction.Arn),
			Name:              pulumi.String("example"),
			TriggerTypes: pulumi.StringArray{
				pulumi.String("ConfigurationItemChangeNotification"),
			},
		}, pulumi.DependsOn([]pulumi.Resource{
			example,
			exampleOrganization,
		}))
		if err != nil {
			return err
		}
		return nil
	})
}
pulumi {
  required_providers {
    aws = {
      source = "pulumi/aws"
    }
  }
}

resource "aws_lambda_permission" "example" {
  action       = "lambda:InvokeFunction"
  function     = exampleAwsLambdaFunction.arn
  principal    = "config.amazonaws.com"
  statement_id = "AllowExecutionFromConfig"
}
resource "aws_organizations_organization" "example" {
  aws_service_access_principals = ["config-multiaccountsetup.amazonaws.com"]
  feature_set                   = "ALL"
}
resource "aws_cfg_organizationcustomrule" "example" {
  depends_on          = [aws_lambda_permission.example, aws_organizations_organization.example]
  lambda_function_arn = exampleAwsLambdaFunction.arn
  name                = "example"
  trigger_types       = ["ConfigurationItemChangeNotification"]
}
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.aws.lambda.Permission;
import com.pulumi.aws.lambda.PermissionArgs;
import com.pulumi.aws.organizations.Organization;
import com.pulumi.aws.organizations.OrganizationArgs;
import com.pulumi.aws.cfg.OrganizationCustomRule;
import com.pulumi.aws.cfg.OrganizationCustomRuleArgs;
import com.pulumi.resources.CustomResourceOptions;
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 example = new Permission("example", PermissionArgs.builder()
            .action("lambda:InvokeFunction")
            .function(exampleAwsLambdaFunction.arn())
            .principal("config.amazonaws.com")
            .statementId("AllowExecutionFromConfig")
            .build());

        var exampleOrganization = new Organization("exampleOrganization", OrganizationArgs.builder()
            .awsServiceAccessPrincipals("config-multiaccountsetup.amazonaws.com")
            .featureSet("ALL")
            .build());

        var exampleOrganizationCustomRule = new OrganizationCustomRule("exampleOrganizationCustomRule", OrganizationCustomRuleArgs.builder()
            .lambdaFunctionArn(exampleAwsLambdaFunction.arn())
            .name("example")
            .triggerTypes("ConfigurationItemChangeNotification")
            .build(), CustomResourceOptions.builder()
                .dependsOn(
                    example,
                    exampleOrganization)
                .build());

    }
}
resources:
  example:
    type: aws:lambda:Permission
    properties:
      action: lambda:InvokeFunction
      function: ${exampleAwsLambdaFunction.arn}
      principal: config.amazonaws.com
      statementId: AllowExecutionFromConfig
  exampleOrganization:
    type: aws:organizations:Organization
    name: example
    properties:
      awsServiceAccessPrincipals:
        - config-multiaccountsetup.amazonaws.com
      featureSet: ALL
  exampleOrganizationCustomRule:
    type: aws:cfg:OrganizationCustomRule
    name: example
    properties:
      lambdaFunctionArn: ${exampleAwsLambdaFunction.arn}
      name: example
      triggerTypes:
        - ConfigurationItemChangeNotification
    options:
      dependsOn:
        - ${example}
        - ${exampleOrganization}

Import

Identity Schema

Required

  • name (String) Name of the rule.

Optional

  • accountId (String) AWS Account where this resource is managed.
  • region (String) Region where this resource is managed.

Using pulumi import, import Config Organization Custom Rules using the name. For example:

$ pulumi import aws:cfg/organizationCustomRule:OrganizationCustomRule example example

Constructors

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

Properties

arn ↔ Output<String>
ARN of the rule
latefinal
childResources → Set<Resource>
finalinherited
completionSources ↔ Map<String, IOutputCompletionSource>
latefinalinherited
description ↔ Output<String?>
Description of the rule
latefinal
excludedAccounts ↔ Output<List<String>?>
List of AWS account identifiers to exclude from the rule
latefinal
hashCode → int
The hash code for this object.
no setterinherited
id ↔ Output<String>
getter/setter pairinherited
inputParameters ↔ Output<String?>
A string in JSON format that is passed to the AWS Config Rule Lambda Function
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
lambdaFunctionArn ↔ Output<String>
ARN of the rule Lambda Function
latefinal
maximumExecutionFrequency ↔ Output<String?>
The maximum frequency with which AWS Config runs evaluations for a rule, if the rule is triggered at a periodic frequency. Defaults to TwentyFour_Hours for periodic frequency triggered rules. Valid values: One_Hour, Three_Hours, Six_Hours, Twelve_Hours, or TwentyFour_Hours.
latefinal
name ↔ Output<String>
The name of the rule
latefinal
region ↔ Output<String>
Region where this resource will be managed. Defaults to the Region set in the provider configuration.
latefinal
resourceIdScope ↔ Output<String?>
Identifier of the AWS resource to evaluate
latefinal
resourceTransforms → List<ResourceTransform>
Inherited/explicit async transforms.
no setterinherited
resourceTypesScopes ↔ Output<List<String>?>
List of types of AWS resources to evaluate
latefinal
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
tagKeyScope ↔ Output<String?>
Tag key of AWS resources to evaluate
latefinal
tagValueScope ↔ Output<String?>
Tag value of AWS resources to evaluate
latefinal
transformations → List<ResourceTransformation>
Inherited/explicit legacy transformations.
no setterinherited
triggerTypes ↔ Output<List<String>>
List of notification types that trigger AWS Config to run an evaluation for the rule. Valid values: ConfigurationItemChangeNotification, OversizedConfigurationItemChangeNotification, and ScheduledNotification
latefinal
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, {OrganizationCustomRuleState? state, CustomResourceOptions? options}) → OrganizationCustomRule
Gets an existing OrganizationCustomRule resource's state with the given name and id.