Policy class

Provides a resource to manage an AWS Organizations policy.

Example Usage

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

const example = aws.iam.getPolicyDocument({
    statements: [{
        effect: "Allow",
        actions: ["*"],
        resources: ["*"],
    }],
});
const examplePolicy = new aws.organizations.Policy("example", {
    name: "example",
    content: example.then(example => example.json),
});
import pulumi
import pulumi_aws as aws

example = aws.iam.get_policy_document(statements=[{
    "effect": "Allow",
    "actions": ["*"],
    "resources": ["*"],
}])
example_policy = aws.organizations.Policy("example",
    name="example",
    content=example.json)
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Aws = Pulumi.Aws;

return await Deployment.RunAsync(() =>
{
    var example = Aws.Iam.GetPolicyDocument.Invoke(new()
    {
        Statements = new[]
        {
            new Aws.Iam.Inputs.GetPolicyDocumentStatementInputArgs
            {
                Effect = "Allow",
                Actions = new[]
                {
                    "*",
                },
                Resources = new[]
                {
                    "*",
                },
            },
        },
    });

    var examplePolicy = new Aws.Organizations.Policy("example", new()
    {
        Name = "example",
        Content = example.Apply(getPolicyDocumentResult => getPolicyDocumentResult.Json),
    });

});
package main

import (
	"github.com/pulumi/pulumi-aws/sdk/v7/go/aws/iam"
	"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 := iam.GetPolicyDocument(ctx, &iam.GetPolicyDocumentArgs{
			Statements: []iam.GetPolicyDocumentStatement{
				{
					Effect: pulumi.StringRef("Allow"),
					Actions: []string{
						"*",
					},
					Resources: []string{
						"*",
					},
				},
			},
		}, nil)
		if err != nil {
			return err
		}
		_, err = organizations.NewPolicy(ctx, "example", &organizations.PolicyArgs{
			Name:    pulumi.String("example"),
			Content: pulumi.String(example.Json),
		})
		if err != nil {
			return err
		}
		return nil
	})
}
pulumi {
  required_providers {
    aws = {
      source = "pulumi/aws"
    }
  }
}

data "aws_iam_getpolicydocument" "example" {
  statements {
    effect    = "Allow"
    actions   = ["*"]
    resources = ["*"]
  }
}

resource "aws_organizations_policy" "example" {
  name    = "example"
  content = data.aws_iam_getpolicydocument.example.json
}
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.aws.iam.IamFunctions;
import com.pulumi.aws.iam.inputs.GetPolicyDocumentArgs;
import com.pulumi.aws.iam.inputs.GetPolicyDocumentStatementArgs;
import com.pulumi.aws.organizations.Policy;
import com.pulumi.aws.organizations.PolicyArgs;
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) {
        final var example = IamFunctions.getPolicyDocument(GetPolicyDocumentArgs.builder()
            .statements(GetPolicyDocumentStatementArgs.builder()
                .effect("Allow")
                .actions("*")
                .resources("*")
                .build())
            .build());

        var examplePolicy = new Policy("examplePolicy", PolicyArgs.builder()
            .name("example")
            .content(example.json())
            .build());

    }
}
resources:
  examplePolicy:
    type: aws:organizations:Policy
    name: example
    properties:
      name: example
      content: ${example.json}
variables:
  example:
    fn::invoke:
      function: aws:iam:getPolicyDocument
      arguments:
        statements:
          - effect: Allow
            actions:
              - '*'
            resources:
              - '*'

Import

Identity Schema

Required

  • id (String) Unique identifier (ID) of the policy.

Optional

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

Using pulumi import, import aws.organizations.Policy using the policy ID. For example:

$ pulumi import aws:organizations/policy:Policy example p-12345678

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
content ↔ Output<String>
The policy content to add to the new policy. For example, if you create a service control policy (SCP), this string must be JSON text that specifies the permissions that admins in attached accounts can delegate to their users, groups, and roles. For more information about the AI Services opt-out Policy syntax, see the AI Services opt-out Policy Syntax documentation. For more information about the Backup Policy syntax, see the Backup Policy Syntax documentation. For more information about the Bedrock Policy syntax, see the Bedrock Policy Syntax documentation. For more information about the Chatbot Policy syntax, see the Chatbot Policy Syntax documentation. For more information about the Declarative Policy syntax, see the Declarative Policy Syntax documentation. For more information about the Inspector Policy syntax, see the Inspector Policy Syntax documentation. For more information about the RCP syntax, see the Resource Control Policy Syntax documentation. For more information about the S3 Policy syntax, see the S3 Policy Syntax documentation. For more information about the Security Hub Policy syntax, see the Security Hub Policy Syntax documentation. For more information about the SCP syntax, see the Service Control Policy Syntax documentation. For more information on the Tag Policy syntax, see the Tag Policy Syntax documentation. For more information about the Upgrade Rollout Policy syntax, see the Upgrade Rollout Policy Syntax documentation.
latefinal
description ↔ Output<String?>
A description to assign to the policy.
latefinal
hashCode → int
The hash code for this object.
no setterinherited
id ↔ Output<String>
getter/setter pairinherited
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>
The friendly name to assign to the policy.
latefinal
resourceTransforms → List<ResourceTransform>
Inherited/explicit async transforms.
no setterinherited
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
skipDestroy ↔ Output<bool?>
If set to true, destroy will not delete the policy and instead just remove the resource from state. This can be useful in situations where the policies (and the associated attachment) must be preserved to meet the AWS minimum requirement of 1 attached policy.
latefinal
tags ↔ Output<Map<String, String>?>
Key-value map 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>>
A 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
type ↔ Output<String?>
The type of policy to create. Valid values are AISERVICES_OPT_OUT_POLICY, BACKUP_POLICY, BEDROCK_POLICY, CHATBOT_POLICY, DECLARATIVE_POLICY_EC2, INSPECTOR_POLICY, RESOURCE_CONTROL_POLICY (RCP), S3_POLICY, SECURITYHUB_POLICY, SERVICE_CONTROL_POLICY (SCP), TAG_POLICY, and UPGRADE_ROLLOUT_POLICY. Defaults to SERVICE_CONTROL_POLICY.
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, {PolicyState? state, CustomResourceOptions? options}) → Policy
Gets an existing Policy resource's state with the given name and id.