1. Packages
  2. AWS
  3. API Docs
  4. glue
  5. ResourcePolicy
AWS v6.77.0 published on Wednesday, Apr 9, 2025 by Pulumi

aws.glue.ResourcePolicy

Explore with Pulumi AI

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)});
Copy
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)
Copy
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, &aws.GetCallerIdentityArgs{}, nil)
		if err != nil {
			return err
		}
		currentGetPartition, err := aws.GetPartition(ctx, &aws.GetPartitionArgs{}, nil)
		if err != nil {
			return err
		}
		currentGetRegion, err := aws.GetRegion(ctx, &aws.GetRegionArgs{}, 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
	})
}
Copy
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)),
    });

});
Copy
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(GetCallerIdentityArgs.builder()
            .build());

        final var currentGetPartition = AwsFunctions.getPartition(GetPartitionArgs.builder()
            .build());

        final var currentGetRegion = AwsFunctions.getRegion(GetRegionArgs.builder()
            .build());

        final var glue-example-policy = IamFunctions.getPolicyDocument(GetPolicyDocumentArgs.builder()
            .statements(GetPolicyDocumentStatementArgs.builder()
                .actions("glue:CreateTable")
                .resources(String.format("arn:%s:glue:%s:%s:*", currentGetPartition.partition(),currentGetRegion.name(),current.accountId()))
                .principals(GetPolicyDocumentStatementPrincipalArgs.builder()
                    .identifiers("*")
                    .type("AWS")
                    .build())
                .build())
            .build());

        var example = new ResourcePolicy("example", ResourcePolicyArgs.builder()
            .policy(glue_example_policy.json())
            .build());

    }
}
Copy
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
Copy

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 This property is required. string
The unique name of the resource.
args This property is required. ResourcePolicyArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
resource_name This property is required. str
The unique name of the resource.
args This property is required. 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 This property is required. string
The unique name of the resource.
args This property is required. ResourcePolicyArgs
The arguments to resource properties.
opts ResourceOption
Bag of options to control resource's behavior.
name This property is required. string
The unique name of the resource.
args This property is required. ResourcePolicyArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
name This property is required. String
The unique name of the resource.
args This property is required. 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",
});
Copy
example, err := glue.NewResourcePolicy(ctx, "exampleresourcePolicyResourceResourceFromGlueresourcePolicy", &glue.ResourcePolicyArgs{
	Policy:       pulumi.String("string"),
	EnableHybrid: pulumi.String("string"),
})
Copy
var exampleresourcePolicyResourceResourceFromGlueresourcePolicy = new ResourcePolicy("exampleresourcePolicyResourceResourceFromGlueresourcePolicy", ResourcePolicyArgs.builder()
    .policy("string")
    .enableHybrid("string")
    .build());
Copy
exampleresource_policy_resource_resource_from_glueresource_policy = aws.glue.ResourcePolicy("exampleresourcePolicyResourceResourceFromGlueresourcePolicy",
    policy="string",
    enable_hybrid="string")
Copy
const exampleresourcePolicyResourceResourceFromGlueresourcePolicy = new aws.glue.ResourcePolicy("exampleresourcePolicyResourceResourceFromGlueresourcePolicy", {
    policy: "string",
    enableHybrid: "string",
});
Copy
type: aws:glue:ResourcePolicy
properties:
    enableHybrid: string
    policy: string
Copy

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

In Python, inputs that are objects can be passed either as argument classes or as dictionary literals.

The ResourcePolicy resource accepts the following input properties:

Policy This property is required. 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 This property is required. 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 This property is required. 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 This property is required. 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 This property is required. 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 This property is required. 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)
resources:  _:    type: aws:glue:ResourcePolicy    get:      id: ${id}
name This property is required.
The unique name of the resulting resource.
id This property is required.
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 This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
name This property is required.
The unique name of the resulting resource.
id This property is required.
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 This property is required.
The unique name of the resulting resource.
id This property is required.
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 This property is required.
The unique name of the resulting resource.
id This property is required.
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
Copy

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.