1. Packages
  2. AWS Classic
  3. API Docs
  4. glue
  5. ResourcePolicy

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.glue.ResourcePolicy

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

    Provides a Glue resource policy. Only one can exist per region.

    Example Usage

    import * as pulumi from "@pulumi/pulumi";
    import * as aws from "@pulumi/aws";
    
    const current = aws.getCallerIdentity({});
    const currentGetPartition = aws.getPartition({});
    const currentGetRegion = aws.getRegion({});
    const glue-example-policy = Promise.all([currentGetPartition, currentGetRegion, current]).then(([currentGetPartition, currentGetRegion, current]) => aws.iam.getPolicyDocument({
        statements: [{
            actions: ["glue:CreateTable"],
            resources: [`arn:${currentGetPartition.partition}:glue:${currentGetRegion.name}:${current.accountId}:*`],
            principals: [{
                identifiers: ["*"],
                type: "AWS",
            }],
        }],
    }));
    const example = new aws.glue.ResourcePolicy("example", {policy: glue_example_policy.then(glue_example_policy => glue_example_policy.json)});
    
    import pulumi
    import pulumi_aws as aws
    
    current = aws.get_caller_identity()
    current_get_partition = aws.get_partition()
    current_get_region = aws.get_region()
    glue_example_policy = aws.iam.get_policy_document(statements=[{
        "actions": ["glue:CreateTable"],
        "resources": [f"arn:{current_get_partition.partition}:glue:{current_get_region.name}:{current.account_id}:*"],
        "principals": [{
            "identifiers": ["*"],
            "type": "AWS",
        }],
    }])
    example = aws.glue.ResourcePolicy("example", policy=glue_example_policy.json)
    
    package main
    
    import (
    	"fmt"
    
    	"github.com/pulumi/pulumi-aws/sdk/v6/go/aws"
    	"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/glue"
    	"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 {
    		current, err := aws.GetCallerIdentity(ctx, nil, nil)
    		if err != nil {
    			return err
    		}
    		currentGetPartition, err := aws.GetPartition(ctx, nil, nil)
    		if err != nil {
    			return err
    		}
    		currentGetRegion, err := aws.GetRegion(ctx, nil, nil)
    		if err != nil {
    			return err
    		}
    		glue_example_policy, err := iam.GetPolicyDocument(ctx, &iam.GetPolicyDocumentArgs{
    			Statements: []iam.GetPolicyDocumentStatement{
    				{
    					Actions: []string{
    						"glue:CreateTable",
    					},
    					Resources: []string{
    						fmt.Sprintf("arn:%v:glue:%v:%v:*", currentGetPartition.Partition, currentGetRegion.Name, current.AccountId),
    					},
    					Principals: []iam.GetPolicyDocumentStatementPrincipal{
    						{
    							Identifiers: []string{
    								"*",
    							},
    							Type: "AWS",
    						},
    					},
    				},
    			},
    		}, nil)
    		if err != nil {
    			return err
    		}
    		_, err = glue.NewResourcePolicy(ctx, "example", &glue.ResourcePolicyArgs{
    			Policy: pulumi.String(glue_example_policy.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 current = Aws.GetCallerIdentity.Invoke();
    
        var currentGetPartition = Aws.GetPartition.Invoke();
    
        var currentGetRegion = Aws.GetRegion.Invoke();
    
        var glue_example_policy = Aws.Iam.GetPolicyDocument.Invoke(new()
        {
            Statements = new[]
            {
                new Aws.Iam.Inputs.GetPolicyDocumentStatementInputArgs
                {
                    Actions = new[]
                    {
                        "glue:CreateTable",
                    },
                    Resources = new[]
                    {
                        $"arn:{currentGetPartition.Apply(getPartitionResult => getPartitionResult.Partition)}:glue:{currentGetRegion.Apply(getRegionResult => getRegionResult.Name)}:{current.Apply(getCallerIdentityResult => getCallerIdentityResult.AccountId)}:*",
                    },
                    Principals = new[]
                    {
                        new Aws.Iam.Inputs.GetPolicyDocumentStatementPrincipalInputArgs
                        {
                            Identifiers = new[]
                            {
                                "*",
                            },
                            Type = "AWS",
                        },
                    },
                },
            },
        });
    
        var example = new Aws.Glue.ResourcePolicy("example", new()
        {
            Policy = glue_example_policy.Apply(glue_example_policy => glue_example_policy.Apply(getPolicyDocumentResult => getPolicyDocumentResult.Json)),
        });
    
    });
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.aws.AwsFunctions;
    import com.pulumi.aws.inputs.GetCallerIdentityArgs;
    import com.pulumi.aws.inputs.GetPartitionArgs;
    import com.pulumi.aws.inputs.GetRegionArgs;
    import com.pulumi.aws.iam.IamFunctions;
    import com.pulumi.aws.iam.inputs.GetPolicyDocumentArgs;
    import com.pulumi.aws.glue.ResourcePolicy;
    import com.pulumi.aws.glue.ResourcePolicyArgs;
    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 current = AwsFunctions.getCallerIdentity();
    
            final var currentGetPartition = AwsFunctions.getPartition();
    
            final var currentGetRegion = AwsFunctions.getRegion();
    
            final var glue-example-policy = IamFunctions.getPolicyDocument(GetPolicyDocumentArgs.builder()
                .statements(GetPolicyDocumentStatementArgs.builder()
                    .actions("glue:CreateTable")
                    .resources(String.format("arn:%s:glue:%s:%s:*", currentGetPartition.applyValue(getPartitionResult -> getPartitionResult.partition()),currentGetRegion.applyValue(getRegionResult -> getRegionResult.name()),current.applyValue(getCallerIdentityResult -> getCallerIdentityResult.accountId())))
                    .principals(GetPolicyDocumentStatementPrincipalArgs.builder()
                        .identifiers("*")
                        .type("AWS")
                        .build())
                    .build())
                .build());
    
            var example = new ResourcePolicy("example", ResourcePolicyArgs.builder()
                .policy(glue_example_policy.json())
                .build());
    
        }
    }
    
    resources:
      example:
        type: aws:glue:ResourcePolicy
        properties:
          policy: ${["glue-example-policy"].json}
    variables:
      current:
        fn::invoke:
          Function: aws:getCallerIdentity
          Arguments: {}
      currentGetPartition:
        fn::invoke:
          Function: aws:getPartition
          Arguments: {}
      currentGetRegion:
        fn::invoke:
          Function: aws:getRegion
          Arguments: {}
      glue-example-policy:
        fn::invoke:
          Function: aws:iam:getPolicyDocument
          Arguments:
            statements:
              - actions:
                  - glue:CreateTable
                resources:
                  - arn:${currentGetPartition.partition}:glue:${currentGetRegion.name}:${current.accountId}:*
                principals:
                  - identifiers:
                      - '*'
                    type: AWS
    

    Create ResourcePolicy Resource

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

    Constructor syntax

    new ResourcePolicy(name: string, args: ResourcePolicyArgs, opts?: CustomResourceOptions);
    @overload
    def ResourcePolicy(resource_name: str,
                       args: ResourcePolicyArgs,
                       opts: Optional[ResourceOptions] = None)
    
    @overload
    def ResourcePolicy(resource_name: str,
                       opts: Optional[ResourceOptions] = None,
                       policy: Optional[str] = None,
                       enable_hybrid: Optional[str] = None)
    func NewResourcePolicy(ctx *Context, name string, args ResourcePolicyArgs, opts ...ResourceOption) (*ResourcePolicy, error)
    public ResourcePolicy(string name, ResourcePolicyArgs args, CustomResourceOptions? opts = null)
    public ResourcePolicy(String name, ResourcePolicyArgs args)
    public ResourcePolicy(String name, ResourcePolicyArgs args, CustomResourceOptions options)
    
    type: aws:glue:ResourcePolicy
    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 ResourcePolicyArgs
    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 ResourcePolicyArgs
    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 ResourcePolicyArgs
    The arguments to resource properties.
    opts ResourceOption
    Bag of options to control resource's behavior.
    name string
    The unique name of the resource.
    args ResourcePolicyArgs
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    name String
    The unique name of the resource.
    args ResourcePolicyArgs
    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 exampleresourcePolicyResourceResourceFromGlueresourcePolicy = new Aws.Glue.ResourcePolicy("exampleresourcePolicyResourceResourceFromGlueresourcePolicy", new()
    {
        Policy = "string",
        EnableHybrid = "string",
    });
    
    example, err := glue.NewResourcePolicy(ctx, "exampleresourcePolicyResourceResourceFromGlueresourcePolicy", &glue.ResourcePolicyArgs{
    	Policy:       pulumi.String("string"),
    	EnableHybrid: pulumi.String("string"),
    })
    
    var exampleresourcePolicyResourceResourceFromGlueresourcePolicy = new ResourcePolicy("exampleresourcePolicyResourceResourceFromGlueresourcePolicy", ResourcePolicyArgs.builder()
        .policy("string")
        .enableHybrid("string")
        .build());
    
    exampleresource_policy_resource_resource_from_glueresource_policy = aws.glue.ResourcePolicy("exampleresourcePolicyResourceResourceFromGlueresourcePolicy",
        policy="string",
        enable_hybrid="string")
    
    const exampleresourcePolicyResourceResourceFromGlueresourcePolicy = new aws.glue.ResourcePolicy("exampleresourcePolicyResourceResourceFromGlueresourcePolicy", {
        policy: "string",
        enableHybrid: "string",
    });
    
    type: aws:glue:ResourcePolicy
    properties:
        enableHybrid: string
        policy: string
    

    ResourcePolicy 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 ResourcePolicy resource accepts the following input properties:

    Policy string
    The policy to be applied to the aws glue data catalog.
    EnableHybrid string
    Indicates that you are using both methods to grant cross-account. Valid values are TRUE and FALSE. Note the provider will not perform drift detetction on this field as its not return on read.
    Policy string
    The policy to be applied to the aws glue data catalog.
    EnableHybrid string
    Indicates that you are using both methods to grant cross-account. Valid values are TRUE and FALSE. Note the provider will not perform drift detetction on this field as its not return on read.
    policy String
    The policy to be applied to the aws glue data catalog.
    enableHybrid String
    Indicates that you are using both methods to grant cross-account. Valid values are TRUE and FALSE. Note the provider will not perform drift detetction on this field as its not return on read.
    policy string
    The policy to be applied to the aws glue data catalog.
    enableHybrid string
    Indicates that you are using both methods to grant cross-account. Valid values are TRUE and FALSE. Note the provider will not perform drift detetction on this field as its not return on read.
    policy str
    The policy to be applied to the aws glue data catalog.
    enable_hybrid str
    Indicates that you are using both methods to grant cross-account. Valid values are TRUE and FALSE. Note the provider will not perform drift detetction on this field as its not return on read.
    policy String
    The policy to be applied to the aws glue data catalog.
    enableHybrid String
    Indicates that you are using both methods to grant cross-account. Valid values are TRUE and FALSE. Note the provider will not perform drift detetction on this field as its not return on read.

    Outputs

    All input properties are implicitly available as output properties. Additionally, the ResourcePolicy 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 ResourcePolicy Resource

    Get an existing ResourcePolicy 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?: ResourcePolicyState, opts?: CustomResourceOptions): ResourcePolicy
    @staticmethod
    def get(resource_name: str,
            id: str,
            opts: Optional[ResourceOptions] = None,
            enable_hybrid: Optional[str] = None,
            policy: Optional[str] = None) -> ResourcePolicy
    func GetResourcePolicy(ctx *Context, name string, id IDInput, state *ResourcePolicyState, opts ...ResourceOption) (*ResourcePolicy, error)
    public static ResourcePolicy Get(string name, Input<string> id, ResourcePolicyState? state, CustomResourceOptions? opts = null)
    public static ResourcePolicy get(String name, Output<String> id, ResourcePolicyState 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:
    EnableHybrid string
    Indicates that you are using both methods to grant cross-account. Valid values are TRUE and FALSE. Note the provider will not perform drift detetction on this field as its not return on read.
    Policy string
    The policy to be applied to the aws glue data catalog.
    EnableHybrid string
    Indicates that you are using both methods to grant cross-account. Valid values are TRUE and FALSE. Note the provider will not perform drift detetction on this field as its not return on read.
    Policy string
    The policy to be applied to the aws glue data catalog.
    enableHybrid String
    Indicates that you are using both methods to grant cross-account. Valid values are TRUE and FALSE. Note the provider will not perform drift detetction on this field as its not return on read.
    policy String
    The policy to be applied to the aws glue data catalog.
    enableHybrid string
    Indicates that you are using both methods to grant cross-account. Valid values are TRUE and FALSE. Note the provider will not perform drift detetction on this field as its not return on read.
    policy string
    The policy to be applied to the aws glue data catalog.
    enable_hybrid str
    Indicates that you are using both methods to grant cross-account. Valid values are TRUE and FALSE. Note the provider will not perform drift detetction on this field as its not return on read.
    policy str
    The policy to be applied to the aws glue data catalog.
    enableHybrid String
    Indicates that you are using both methods to grant cross-account. Valid values are TRUE and FALSE. Note the provider will not perform drift detetction on this field as its not return on read.
    policy String
    The policy to be applied to the aws glue data catalog.

    Import

    Using pulumi import, import Glue Resource Policy using the account ID. For example:

    $ pulumi import aws:glue/resourcePolicy:ResourcePolicy Test 12356789012
    

    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