1. Packages
  2. AWS Classic
  3. API Docs
  4. acmpca
  5. Policy

Try AWS Native preview for resources not in the classic version.

AWS Classic v6.42.0 published on Wednesday, Jun 26, 2024 by Pulumi

aws.acmpca.Policy

Explore with Pulumi AI

aws logo

Try AWS Native preview for resources not in the classic version.

AWS Classic v6.42.0 published on Wednesday, Jun 26, 2024 by Pulumi

    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: [
            {
                sid: "1",
                effect: "Allow",
                principals: [{
                    type: "AWS",
                    identifiers: [current.accountId],
                }],
                actions: [
                    "acm-pca:DescribeCertificateAuthority",
                    "acm-pca:GetCertificate",
                    "acm-pca:GetCertificateAuthorityCertificate",
                    "acm-pca:ListPermissions",
                    "acm-pca:ListTags",
                ],
                resources: [exampleAwsAcmpcaCertificateAuthority.arn],
            },
            {
                sid: "2",
                effect: allow,
                principals: [{
                    type: "AWS",
                    identifiers: [current.accountId],
                }],
                actions: ["acm-pca:IssueCertificate"],
                resources: [exampleAwsAcmpcaCertificateAuthority.arn],
                conditions: [{
                    test: "StringEquals",
                    variable: "acm-pca:TemplateArn",
                    values: ["arn:aws:acm-pca:::template/EndEntityCertificate/V1"],
                }],
            },
        ],
    });
    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=[
        {
            "sid": "1",
            "effect": "Allow",
            "principals": [{
                "type": "AWS",
                "identifiers": [current["accountId"]],
            }],
            "actions": [
                "acm-pca:DescribeCertificateAuthority",
                "acm-pca:GetCertificate",
                "acm-pca:GetCertificateAuthorityCertificate",
                "acm-pca:ListPermissions",
                "acm-pca:ListTags",
            ],
            "resources": [example_aws_acmpca_certificate_authority["arn"]],
        },
        {
            "sid": "2",
            "effect": allow,
            "principals": [{
                "type": "AWS",
                "identifiers": [current["accountId"]],
            }],
            "actions": ["acm-pca:IssueCertificate"],
            "resources": [example_aws_acmpca_certificate_authority["arn"]],
            "conditions": [{
                "test": "StringEquals",
                "variable": "acm-pca:TemplateArn",
                "values": ["arn:aws:acm-pca:::template/EndEntityCertificate/V1"],
            }],
        },
    ])
    example_policy = aws.acmpca.Policy("example",
        resource_arn=example_aws_acmpca_certificate_authority["arn"],
        policy=example.json)
    
    package main
    
    import (
    	"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/acmpca"
    	"github.com/pulumi/pulumi-aws/sdk/v6/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{
    {
    Sid: pulumi.StringRef("1"),
    Effect: pulumi.StringRef("Allow"),
    Principals: []iam.GetPolicyDocumentStatementPrincipal{
    {
    Type: "AWS",
    Identifiers: interface{}{
    current.AccountId,
    },
    },
    },
    Actions: []string{
    "acm-pca:DescribeCertificateAuthority",
    "acm-pca:GetCertificate",
    "acm-pca:GetCertificateAuthorityCertificate",
    "acm-pca:ListPermissions",
    "acm-pca:ListTags",
    },
    Resources: interface{}{
    exampleAwsAcmpcaCertificateAuthority.Arn,
    },
    },
    {
    Sid: pulumi.StringRef("2"),
    Effect: pulumi.StringRef(allow),
    Principals: []iam.GetPolicyDocumentStatementPrincipal{
    {
    Type: "AWS",
    Identifiers: interface{}{
    current.AccountId,
    },
    },
    },
    Actions: []string{
    "acm-pca:IssueCertificate",
    },
    Resources: interface{}{
    exampleAwsAcmpcaCertificateAuthority.Arn,
    },
    Conditions: []iam.GetPolicyDocumentStatementCondition{
    {
    Test: "StringEquals",
    Variable: "acm-pca:TemplateArn",
    Values: []string{
    "arn:aws:acm-pca:::template/EndEntityCertificate/V1",
    },
    },
    },
    },
    },
    }, 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
    })
    }
    
    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
                {
                    Sid = "1",
                    Effect = "Allow",
                    Principals = new[]
                    {
                        new Aws.Iam.Inputs.GetPolicyDocumentStatementPrincipalInputArgs
                        {
                            Type = "AWS",
                            Identifiers = new[]
                            {
                                current.AccountId,
                            },
                        },
                    },
                    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
                {
                    Sid = "2",
                    Effect = allow,
                    Principals = new[]
                    {
                        new Aws.Iam.Inputs.GetPolicyDocumentStatementPrincipalInputArgs
                        {
                            Type = "AWS",
                            Identifiers = new[]
                            {
                                current.AccountId,
                            },
                        },
                    },
                    Actions = new[]
                    {
                        "acm-pca:IssueCertificate",
                    },
                    Resources = new[]
                    {
                        exampleAwsAcmpcaCertificateAuthority.Arn,
                    },
                    Conditions = new[]
                    {
                        new Aws.Iam.Inputs.GetPolicyDocumentStatementConditionInputArgs
                        {
                            Test = "StringEquals",
                            Variable = "acm-pca:TemplateArn",
                            Values = new[]
                            {
                                "arn:aws:acm-pca:::template/EndEntityCertificate/V1",
                            },
                        },
                    },
                },
            },
        });
    
        var examplePolicy = new Aws.Acmpca.Policy("example", new()
        {
            ResourceArn = exampleAwsAcmpcaCertificateAuthority.Arn,
            PolicyDetails = example.Apply(getPolicyDocumentResult => getPolicyDocumentResult.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.acmpca.Policy;
    import com.pulumi.aws.acmpca.PolicyArgs;
    import java.util.List;
    import java.util.ArrayList;
    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()
                        .sid("1")
                        .effect("Allow")
                        .principals(GetPolicyDocumentStatementPrincipalArgs.builder()
                            .type("AWS")
                            .identifiers(current.accountId())
                            .build())
                        .actions(                    
                            "acm-pca:DescribeCertificateAuthority",
                            "acm-pca:GetCertificate",
                            "acm-pca:GetCertificateAuthorityCertificate",
                            "acm-pca:ListPermissions",
                            "acm-pca:ListTags")
                        .resources(exampleAwsAcmpcaCertificateAuthority.arn())
                        .build(),
                    GetPolicyDocumentStatementArgs.builder()
                        .sid("2")
                        .effect(allow)
                        .principals(GetPolicyDocumentStatementPrincipalArgs.builder()
                            .type("AWS")
                            .identifiers(current.accountId())
                            .build())
                        .actions("acm-pca:IssueCertificate")
                        .resources(exampleAwsAcmpcaCertificateAuthority.arn())
                        .conditions(GetPolicyDocumentStatementConditionArgs.builder()
                            .test("StringEquals")
                            .variable("acm-pca:TemplateArn")
                            .values("arn:aws:acm-pca:::template/EndEntityCertificate/V1")
                            .build())
                        .build())
                .build());
    
            var examplePolicy = new Policy("examplePolicy", PolicyArgs.builder()
                .resourceArn(exampleAwsAcmpcaCertificateAuthority.arn())
                .policy(example.applyValue(getPolicyDocumentResult -> getPolicyDocumentResult.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:
              - sid: '1'
                effect: Allow
                principals:
                  - type: AWS
                    identifiers:
                      - ${current.accountId}
                actions:
                  - acm-pca:DescribeCertificateAuthority
                  - acm-pca:GetCertificate
                  - acm-pca:GetCertificateAuthorityCertificate
                  - acm-pca:ListPermissions
                  - acm-pca:ListTags
                resources:
                  - ${exampleAwsAcmpcaCertificateAuthority.arn}
              - sid: '2'
                effect: ${allow}
                principals:
                  - type: AWS
                    identifiers:
                      - ${current.accountId}
                actions:
                  - acm-pca:IssueCertificate
                resources:
                  - ${exampleAwsAcmpcaCertificateAuthority.arn}
                conditions:
                  - test: StringEquals
                    variable: acm-pca:TemplateArn
                    values:
                      - arn:aws:acm-pca:::template/EndEntityCertificate/V1
    

    Create Policy Resource

    Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.

    Constructor syntax

    new Policy(name: string, args: PolicyArgs, opts?: CustomResourceOptions);
    @overload
    def Policy(resource_name: str,
               args: PolicyArgs,
               opts: Optional[ResourceOptions] = None)
    
    @overload
    def Policy(resource_name: str,
               opts: Optional[ResourceOptions] = None,
               policy: Optional[str] = None,
               resource_arn: Optional[str] = None)
    func NewPolicy(ctx *Context, name string, args PolicyArgs, opts ...ResourceOption) (*Policy, error)
    public Policy(string name, PolicyArgs args, CustomResourceOptions? opts = null)
    public Policy(String name, PolicyArgs args)
    public Policy(String name, PolicyArgs args, CustomResourceOptions options)
    
    type: aws:acmpca:Policy
    properties: # The arguments to resource properties.
    options: # Bag of options to control resource's behavior.
    
    

    Parameters

    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.
    name String
    The unique name of the resource.
    args PolicyArgs
    The arguments to resource properties.
    options CustomResourceOptions
    Bag of options to control resource's behavior.

    Constructor example

    The following reference example uses placeholder values for all input properties.

    var policyResource = new Aws.Acmpca.Policy("policyResource", new()
    {
        PolicyDetails = "string",
        ResourceArn = "string",
    });
    
    example, err := acmpca.NewPolicy(ctx, "policyResource", &acmpca.PolicyArgs{
    	Policy:      pulumi.String("string"),
    	ResourceArn: pulumi.String("string"),
    })
    
    var policyResource = new Policy("policyResource", PolicyArgs.builder()
        .policy("string")
        .resourceArn("string")
        .build());
    
    policy_resource = aws.acmpca.Policy("policyResource",
        policy="string",
        resource_arn="string")
    
    const policyResource = new aws.acmpca.Policy("policyResource", {
        policy: "string",
        resourceArn: "string",
    });
    
    type: aws:acmpca:Policy
    properties:
        policy: string
        resourceArn: string
    

    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:

    PolicyDetails string
    JSON-formatted IAM policy to attach to the specified private CA resource.
    ResourceArn string
    ARN of the private CA to associate with the policy.
    Policy string
    JSON-formatted IAM policy to attach to the specified private CA resource.
    ResourceArn string
    ARN of the private CA to associate with the policy.
    policy String
    JSON-formatted IAM policy to attach to the specified private CA resource.
    resourceArn String
    ARN of the private CA to associate with the policy.
    policy string
    JSON-formatted IAM policy to attach to the specified private CA resource.
    resourceArn string
    ARN of the private CA to associate with the policy.
    policy str
    JSON-formatted IAM policy to attach to the specified private CA resource.
    resource_arn str
    ARN of the private CA to associate with the policy.
    policy String
    JSON-formatted IAM policy to attach to the specified private CA resource.
    resourceArn String
    ARN of the private CA to associate with the policy.

    Outputs

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

    Id string
    The provider-assigned unique ID for this managed resource.
    Id string
    The provider-assigned unique ID for this managed resource.
    id String
    The provider-assigned unique ID for this managed resource.
    id string
    The provider-assigned unique ID for this managed resource.
    id str
    The provider-assigned unique ID for this managed resource.
    id String
    The provider-assigned unique ID for this managed resource.

    Look up 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,
            policy: Optional[str] = None,
            resource_arn: Optional[str] = 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)
    public static Policy get(String name, Output<String> id, PolicyState state, CustomResourceOptions options)
    Resource lookup is not supported in YAML
    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.
    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:
    PolicyDetails string
    JSON-formatted IAM policy to attach to the specified private CA resource.
    ResourceArn string
    ARN of the private CA to associate with the policy.
    Policy string
    JSON-formatted IAM policy to attach to the specified private CA resource.
    ResourceArn string
    ARN of the private CA to associate with the policy.
    policy String
    JSON-formatted IAM policy to attach to the specified private CA resource.
    resourceArn String
    ARN of the private CA to associate with the policy.
    policy string
    JSON-formatted IAM policy to attach to the specified private CA resource.
    resourceArn string
    ARN of the private CA to associate with the policy.
    policy str
    JSON-formatted IAM policy to attach to the specified private CA resource.
    resource_arn str
    ARN of the private CA to associate with the policy.
    policy String
    JSON-formatted IAM policy to attach to the specified private CA resource.
    resourceArn String
    ARN of the private CA to associate with the policy.

    Import

    Using pulumi import, import aws_acmpca_policy using the resource_arn 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
    

    To learn more about importing existing cloud resources, see Importing resources.

    Package Details

    Repository
    AWS Classic pulumi/pulumi-aws
    License
    Apache-2.0
    Notes
    This Pulumi package is based on the aws Terraform Provider.
    aws logo

    Try AWS Native preview for resources not in the classic version.

    AWS Classic v6.42.0 published on Wednesday, Jun 26, 2024 by Pulumi