Policy class

Attaches a resource based policy to a private CA.

Example Usage

Basic

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

const example = aws.iam.getPolicyDocument({
    statements: [
        {
            principals: [{
                type: "AWS",
                identifiers: [current.accountId],
            }],
            sid: "1",
            effect: "Allow",
            actions: [
                "acm-pca:DescribeCertificateAuthority",
                "acm-pca:GetCertificate",
                "acm-pca:GetCertificateAuthorityCertificate",
                "acm-pca:ListPermissions",
                "acm-pca:ListTags",
            ],
            resources: [exampleAwsAcmpcaCertificateAuthority.arn],
        },
        {
            conditions: [{
                test: "StringEquals",
                variable: "acm-pca:TemplateArn",
                values: ["arn:aws:acm-pca:::template/EndEntityCertificate/V1"],
            }],
            principals: [{
                type: "AWS",
                identifiers: [current.accountId],
            }],
            sid: "2",
            effect: allow,
            actions: ["acm-pca:IssueCertificate"],
            resources: [exampleAwsAcmpcaCertificateAuthority.arn],
        },
    ],
});
const examplePolicy = new aws.acmpca.Policy("example", {
    resourceArn: exampleAwsAcmpcaCertificateAuthority.arn,
    policy: example.then(example => example.json),
});
import pulumi
import pulumi_aws as aws

example = aws.iam.get_policy_document(statements=[
    {
        "principals": [{
            "type": "AWS",
            "identifiers": [current["accountId"]],
        }],
        "sid": "1",
        "effect": "Allow",
        "actions": [
            "acm-pca:DescribeCertificateAuthority",
            "acm-pca:GetCertificate",
            "acm-pca:GetCertificateAuthorityCertificate",
            "acm-pca:ListPermissions",
            "acm-pca:ListTags",
        ],
        "resources": [example_aws_acmpca_certificate_authority["arn"]],
    },
    {
        "conditions": [{
            "test": "StringEquals",
            "variable": "acm-pca:TemplateArn",
            "values": ["arn:aws:acm-pca:::template/EndEntityCertificate/V1"],
        }],
        "principals": [{
            "type": "AWS",
            "identifiers": [current["accountId"]],
        }],
        "sid": "2",
        "effect": allow,
        "actions": ["acm-pca:IssueCertificate"],
        "resources": [example_aws_acmpca_certificate_authority["arn"]],
    },
])
example_policy = aws.acmpca.Policy("example",
    resource_arn=example_aws_acmpca_certificate_authority["arn"],
    policy=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
            {
                Principals = new[]
                {
                    new Aws.Iam.Inputs.GetPolicyDocumentStatementPrincipalInputArgs
                    {
                        Type = "AWS",
                        Identifiers = new[]
                        {
                            current.AccountId,
                        },
                    },
                },
                Sid = "1",
                Effect = "Allow",
                Actions = new[]
                {
                    "acm-pca:DescribeCertificateAuthority",
                    "acm-pca:GetCertificate",
                    "acm-pca:GetCertificateAuthorityCertificate",
                    "acm-pca:ListPermissions",
                    "acm-pca:ListTags",
                },
                Resources = new[]
                {
                    exampleAwsAcmpcaCertificateAuthority.Arn,
                },
            },
            new Aws.Iam.Inputs.GetPolicyDocumentStatementInputArgs
            {
                Conditions = new[]
                {
                    new Aws.Iam.Inputs.GetPolicyDocumentStatementConditionInputArgs
                    {
                        Test = "StringEquals",
                        Variable = "acm-pca:TemplateArn",
                        Values = new[]
                        {
                            "arn:aws:acm-pca:::template/EndEntityCertificate/V1",
                        },
                    },
                },
                Principals = new[]
                {
                    new Aws.Iam.Inputs.GetPolicyDocumentStatementPrincipalInputArgs
                    {
                        Type = "AWS",
                        Identifiers = new[]
                        {
                            current.AccountId,
                        },
                    },
                },
                Sid = "2",
                Effect = allow,
                Actions = new[]
                {
                    "acm-pca:IssueCertificate",
                },
                Resources = new[]
                {
                    exampleAwsAcmpcaCertificateAuthority.Arn,
                },
            },
        },
    });

    var examplePolicy = new Aws.Acmpca.Policy("example", new()
    {
        ResourceArn = exampleAwsAcmpcaCertificateAuthority.Arn,
        PolicyDetails = example.Apply(getPolicyDocumentResult => getPolicyDocumentResult.Json),
    });

});
package main

import (
	"github.com/pulumi/pulumi-aws/sdk/v7/go/aws/acmpca"
	"github.com/pulumi/pulumi-aws/sdk/v7/go/aws/iam"
	"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{
				{
					Principals: []iam.GetPolicyDocumentStatementPrincipal{
						{
							Type: "AWS",
							Identifiers: pulumi.StringArray{
								current.AccountId,
							},
						},
					},
					Sid:    pulumi.StringRef("1"),
					Effect: pulumi.StringRef("Allow"),
					Actions: []string{
						"acm-pca:DescribeCertificateAuthority",
						"acm-pca:GetCertificate",
						"acm-pca:GetCertificateAuthorityCertificate",
						"acm-pca:ListPermissions",
						"acm-pca:ListTags",
					},
					Resources: pulumi.StringArray{
						exampleAwsAcmpcaCertificateAuthority.Arn,
					},
				},
				{
					Conditions: []iam.GetPolicyDocumentStatementCondition{
						{
							Test:     "StringEquals",
							Variable: "acm-pca:TemplateArn",
							Values: []string{
								"arn:aws:acm-pca:::template/EndEntityCertificate/V1",
							},
						},
					},
					Principals: []iam.GetPolicyDocumentStatementPrincipal{
						{
							Type: "AWS",
							Identifiers: pulumi.StringArray{
								current.AccountId,
							},
						},
					},
					Sid:    pulumi.StringRef("2"),
					Effect: pulumi.StringRef(allow),
					Actions: []string{
						"acm-pca:IssueCertificate",
					},
					Resources: pulumi.StringArray{
						exampleAwsAcmpcaCertificateAuthority.Arn,
					},
				},
			},
		}, nil)
		if err != nil {
			return err
		}
		_, err = acmpca.NewPolicy(ctx, "example", &acmpca.PolicyArgs{
			ResourceArn: pulumi.Any(exampleAwsAcmpcaCertificateAuthority.Arn),
			Policy:      pulumi.String(example.Json),
		})
		if err != nil {
			return err
		}
		return nil
	})
}
pulumi {
  required_providers {
    aws = {
      source = "pulumi/aws"
    }
  }
}

data "aws_iam_getpolicydocument" "example" {
  statements {
    principals {
      type        = "AWS"
      identifiers = [current.accountId]
    }
    sid       = "1"
    effect    = "Allow"
    actions   = ["acm-pca:DescribeCertificateAuthority", "acm-pca:GetCertificate", "acm-pca:GetCertificateAuthorityCertificate", "acm-pca:ListPermissions", "acm-pca:ListTags"]
    resources = [exampleAwsAcmpcaCertificateAuthority.arn]
  }
  statements {
    conditions {
      test     = "StringEquals"
      variable = "acm-pca:TemplateArn"
      values   = ["arn:aws:acm-pca:::template/EndEntityCertificate/V1"]
    }
    principals {
      type        = "AWS"
      identifiers = [current.accountId]
    }
    sid       = "2"
    effect    = allow
    actions   = ["acm-pca:IssueCertificate"]
    resources = [exampleAwsAcmpcaCertificateAuthority.arn]
  }
}

resource "aws_acmpca_policy" "example" {
  resource_arn = exampleAwsAcmpcaCertificateAuthority.arn
  policy       = 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.iam.inputs.GetPolicyDocumentStatementPrincipalArgs;
import com.pulumi.aws.iam.inputs.GetPolicyDocumentStatementConditionArgs;
import com.pulumi.aws.acmpca.Policy;
import com.pulumi.aws.acmpca.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()
                    .principals(GetPolicyDocumentStatementPrincipalArgs.builder()
                        .type("AWS")
                        .identifiers(current.accountId())
                        .build())
                    .sid("1")
                    .effect("Allow")
                    .actions(
                        "acm-pca:DescribeCertificateAuthority",
                        "acm-pca:GetCertificate",
                        "acm-pca:GetCertificateAuthorityCertificate",
                        "acm-pca:ListPermissions",
                        "acm-pca:ListTags")
                    .resources(exampleAwsAcmpcaCertificateAuthority.arn())
                    .build(),
                GetPolicyDocumentStatementArgs.builder()
                    .conditions(GetPolicyDocumentStatementConditionArgs.builder()
                        .test("StringEquals")
                        .variable("acm-pca:TemplateArn")
                        .values("arn:aws:acm-pca:::template/EndEntityCertificate/V1")
                        .build())
                    .principals(GetPolicyDocumentStatementPrincipalArgs.builder()
                        .type("AWS")
                        .identifiers(current.accountId())
                        .build())
                    .sid("2")
                    .effect(allow)
                    .actions("acm-pca:IssueCertificate")
                    .resources(exampleAwsAcmpcaCertificateAuthority.arn())
                    .build())
            .build());

        var examplePolicy = new Policy("examplePolicy", PolicyArgs.builder()
            .resourceArn(exampleAwsAcmpcaCertificateAuthority.arn())
            .policy(example.json())
            .build());

    }
}
resources:
  examplePolicy:
    type: aws:acmpca:Policy
    name: example
    properties:
      resourceArn: ${exampleAwsAcmpcaCertificateAuthority.arn}
      policy: ${example.json}
variables:
  example:
    fn::invoke:
      function: aws:iam:getPolicyDocument
      arguments:
        statements:
          - principals:
              - type: AWS
                identifiers:
                  - ${current.accountId}
            sid: '1'
            effect: Allow
            actions:
              - acm-pca:DescribeCertificateAuthority
              - acm-pca:GetCertificate
              - acm-pca:GetCertificateAuthorityCertificate
              - acm-pca:ListPermissions
              - acm-pca:ListTags
            resources:
              - ${exampleAwsAcmpcaCertificateAuthority.arn}
          - conditions:
              - test: StringEquals
                variable: acm-pca:TemplateArn
                values:
                  - arn:aws:acm-pca:::template/EndEntityCertificate/V1
            principals:
              - type: AWS
                identifiers:
                  - ${current.accountId}
            sid: '2'
            effect: ${allow}
            actions:
              - acm-pca:IssueCertificate
            resources:
              - ${exampleAwsAcmpcaCertificateAuthority.arn}

Import

Identity Schema

Required

  • resourceArn (String) ARN of the ACM PCA certificate authority.

Using pulumi import, import aws.acmpca.Policy using the resourceArn value. For example:

$ pulumi import aws:acmpca/policy:Policy example arn:aws:acm-pca:us-east-1:123456789012:certificate-authority/12345678-1234-1234-1234-123456789012

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

childResources → Set<Resource>
finalinherited
completionSources ↔ Map<String, IOutputCompletionSource>
latefinalinherited
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
policy ↔ Output<String>
JSON-formatted IAM policy to attach to the specified private CA resource.
latefinal
region ↔ Output<String>
Region where this resource will be managed. Defaults to the Region set in the provider configuration.
latefinal
resourceArn ↔ Output<String>
ARN of the private CA to associate with 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
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.