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 v5.41.0 published on Monday, May 15, 2023 by Pulumi

aws.acmpca.Policy

Explore with Pulumi AI

aws logo

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

AWS Classic v5.41.0 published on Monday, May 15, 2023 by Pulumi

    Attaches a resource based policy to a private CA.

    Example Usage

    Basic

    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using Aws = Pulumi.Aws;
    
    return await Deployment.RunAsync(() => 
    {
        var examplePolicyDocument = 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[]
                            {
                                data.Aws_caller_identity.Current.Account_id,
                            },
                        },
                    },
                    Actions = new[]
                    {
                        "acm-pca:DescribeCertificateAuthority",
                        "acm-pca:GetCertificate",
                        "acm-pca:GetCertificateAuthorityCertificate",
                        "acm-pca:ListPermissions",
                        "acm-pca:ListTags",
                    },
                    Resources = new[]
                    {
                        aws_acmpca_certificate_authority.Example.Arn,
                    },
                },
                new Aws.Iam.Inputs.GetPolicyDocumentStatementInputArgs
                {
                    Sid = "2",
                    Effect = Allow,
                    Principals = new[]
                    {
                        new Aws.Iam.Inputs.GetPolicyDocumentStatementPrincipalInputArgs
                        {
                            Type = "AWS",
                            Identifiers = new[]
                            {
                                data.Aws_caller_identity.Current.Account_id,
                            },
                        },
                    },
                    Actions = new[]
                    {
                        "acm-pca:IssueCertificate",
                    },
                    Resources = new[]
                    {
                        aws_acmpca_certificate_authority.Example.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("examplePolicy", new()
        {
            ResourceArn = aws_acmpca_certificate_authority.Example.Arn,
            PolicyDetails = examplePolicyDocument.Apply(getPolicyDocumentResult => getPolicyDocumentResult.Json),
        });
    
    });
    

    Coming soon!

    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 examplePolicyDocument = IamFunctions.getPolicyDocument(GetPolicyDocumentArgs.builder()
                .statements(            
                    GetPolicyDocumentStatementArgs.builder()
                        .sid("1")
                        .effect("Allow")
                        .principals(GetPolicyDocumentStatementPrincipalArgs.builder()
                            .type("AWS")
                            .identifiers(data.aws_caller_identity().current().account_id())
                            .build())
                        .actions(                    
                            "acm-pca:DescribeCertificateAuthority",
                            "acm-pca:GetCertificate",
                            "acm-pca:GetCertificateAuthorityCertificate",
                            "acm-pca:ListPermissions",
                            "acm-pca:ListTags")
                        .resources(aws_acmpca_certificate_authority.example().arn())
                        .build(),
                    GetPolicyDocumentStatementArgs.builder()
                        .sid("2")
                        .effect(Allow)
                        .principals(GetPolicyDocumentStatementPrincipalArgs.builder()
                            .type("AWS")
                            .identifiers(data.aws_caller_identity().current().account_id())
                            .build())
                        .actions("acm-pca:IssueCertificate")
                        .resources(aws_acmpca_certificate_authority.example().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(aws_acmpca_certificate_authority.example().arn())
                .policy(examplePolicyDocument.applyValue(getPolicyDocumentResult -> getPolicyDocumentResult.json()))
                .build());
    
        }
    }
    
    import pulumi
    import pulumi_aws as aws
    
    example_policy_document = aws.iam.get_policy_document(statements=[
        aws.iam.GetPolicyDocumentStatementArgs(
            sid="1",
            effect="Allow",
            principals=[aws.iam.GetPolicyDocumentStatementPrincipalArgs(
                type="AWS",
                identifiers=[data["aws_caller_identity"]["current"]["account_id"]],
            )],
            actions=[
                "acm-pca:DescribeCertificateAuthority",
                "acm-pca:GetCertificate",
                "acm-pca:GetCertificateAuthorityCertificate",
                "acm-pca:ListPermissions",
                "acm-pca:ListTags",
            ],
            resources=[aws_acmpca_certificate_authority["example"]["arn"]],
        ),
        aws.iam.GetPolicyDocumentStatementArgs(
            sid="2",
            effect=allow,
            principals=[aws.iam.GetPolicyDocumentStatementPrincipalArgs(
                type="AWS",
                identifiers=[data["aws_caller_identity"]["current"]["account_id"]],
            )],
            actions=["acm-pca:IssueCertificate"],
            resources=[aws_acmpca_certificate_authority["example"]["arn"]],
            conditions=[aws.iam.GetPolicyDocumentStatementConditionArgs(
                test="StringEquals",
                variable="acm-pca:TemplateArn",
                values=["arn:aws:acm-pca:::template/EndEntityCertificate/V1"],
            )],
        ),
    ])
    example_policy = aws.acmpca.Policy("examplePolicy",
        resource_arn=aws_acmpca_certificate_authority["example"]["arn"],
        policy=example_policy_document.json)
    
    import * as pulumi from "@pulumi/pulumi";
    import * as aws from "@pulumi/aws";
    
    const examplePolicyDocument = aws.iam.getPolicyDocument({
        statements: [
            {
                sid: "1",
                effect: "Allow",
                principals: [{
                    type: "AWS",
                    identifiers: [data.aws_caller_identity.current.account_id],
                }],
                actions: [
                    "acm-pca:DescribeCertificateAuthority",
                    "acm-pca:GetCertificate",
                    "acm-pca:GetCertificateAuthorityCertificate",
                    "acm-pca:ListPermissions",
                    "acm-pca:ListTags",
                ],
                resources: [aws_acmpca_certificate_authority.example.arn],
            },
            {
                sid: "2",
                effect: Allow,
                principals: [{
                    type: "AWS",
                    identifiers: [data.aws_caller_identity.current.account_id],
                }],
                actions: ["acm-pca:IssueCertificate"],
                resources: [aws_acmpca_certificate_authority.example.arn],
                conditions: [{
                    test: "StringEquals",
                    variable: "acm-pca:TemplateArn",
                    values: ["arn:aws:acm-pca:::template/EndEntityCertificate/V1"],
                }],
            },
        ],
    });
    const examplePolicy = new aws.acmpca.Policy("examplePolicy", {
        resourceArn: aws_acmpca_certificate_authority.example.arn,
        policy: examplePolicyDocument.then(examplePolicyDocument => examplePolicyDocument.json),
    });
    
    resources:
      examplePolicy:
        type: aws:acmpca:Policy
        properties:
          resourceArn: ${aws_acmpca_certificate_authority.example.arn}
          policy: ${examplePolicyDocument.json}
    variables:
      examplePolicyDocument:
        fn::invoke:
          Function: aws:iam:getPolicyDocument
          Arguments:
            statements:
              - sid: '1'
                effect: Allow
                principals:
                  - type: AWS
                    identifiers:
                      - ${data.aws_caller_identity.current.account_id}
                actions:
                  - acm-pca:DescribeCertificateAuthority
                  - acm-pca:GetCertificate
                  - acm-pca:GetCertificateAuthorityCertificate
                  - acm-pca:ListPermissions
                  - acm-pca:ListTags
                resources:
                  - ${aws_acmpca_certificate_authority.example.arn}
              - sid: '2'
                effect: ${Allow}
                principals:
                  - type: AWS
                    identifiers:
                      - ${data.aws_caller_identity.current.account_id}
                actions:
                  - acm-pca:IssueCertificate
                resources:
                  - ${aws_acmpca_certificate_authority.example.arn}
                conditions:
                  - test: StringEquals
                    variable: acm-pca:TemplateArn
                    values:
                      - arn:aws:acm-pca:::template/EndEntityCertificate/V1
    

    Create Policy Resource

    new Policy(name: string, args: PolicyArgs, opts?: CustomResourceOptions);
    @overload
    def Policy(resource_name: str,
               opts: Optional[ResourceOptions] = None,
               policy: Optional[str] = None,
               resource_arn: Optional[str] = None)
    @overload
    def Policy(resource_name: str,
               args: PolicyArgs,
               opts: Optional[ResourceOptions] = 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.
    
    
    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.

    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

    aws_acmpca_policy can be imported using the resource_arn value.

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

    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 v5.41.0 published on Monday, May 15, 2023 by Pulumi