aws logo
AWS Classic v5.32.0, Mar 17 23

aws.opensearch.DomainPolicy

Allows setting policy to an OpenSearch domain while referencing domain attributes (e.g., ARN).

Example Usage

Coming soon!

Coming soon!

package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.aws.opensearch.Domain;
import com.pulumi.aws.opensearch.DomainArgs;
import com.pulumi.aws.iam.IamFunctions;
import com.pulumi.aws.iam.inputs.GetPolicyDocumentArgs;
import com.pulumi.aws.opensearch.DomainPolicy;
import com.pulumi.aws.opensearch.DomainPolicyArgs;
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) {
        var example = new Domain("example", DomainArgs.builder()        
            .engineVersion("OpenSearch_1.1")
            .build());

        final var mainPolicyDocument = IamFunctions.getPolicyDocument(GetPolicyDocumentArgs.builder()
            .effect("Allow")
            .principals(%!v(PANIC=Format method: runtime error: invalid memory address or nil pointer dereference))
            .actions("es:*")
            .resources(example.arn().applyValue(arn -> String.format("%s/*", arn)))
            .condition(%!v(PANIC=Format method: runtime error: invalid memory address or nil pointer dereference))
            .build());

        var mainDomainPolicy = new DomainPolicy("mainDomainPolicy", DomainPolicyArgs.builder()        
            .domainName(example.domainName())
            .accessPolicies(mainPolicyDocument.applyValue(getPolicyDocumentResult -> getPolicyDocumentResult).applyValue(mainPolicyDocument -> mainPolicyDocument.applyValue(getPolicyDocumentResult -> getPolicyDocumentResult.json())))
            .build());

    }
}

Coming soon!

Coming soon!

resources:
  example:
    type: aws:opensearch:Domain
    properties:
      engineVersion: OpenSearch_1.1
  mainDomainPolicy:
    type: aws:opensearch:DomainPolicy
    properties:
      domainName: ${example.domainName}
      accessPolicies: ${mainPolicyDocument.json}
variables:
  mainPolicyDocument:
    fn::invoke:
      Function: aws:iam:getPolicyDocument
      Arguments:
        effect: Allow
        principals:
          - type: '*'
            identifiers:
              - '*'
        actions:
          - es:*
        resources:
          - ${example.arn}/*
        condition:
          - test: IpAddress
            variable: aws:SourceIp
            values: 127.0.0.1/32

Create DomainPolicy Resource

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

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

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

AccessPolicies string

IAM policy document specifying the access policies for the domain

DomainName string

Name of the domain.

AccessPolicies string

IAM policy document specifying the access policies for the domain

DomainName string

Name of the domain.

accessPolicies String

IAM policy document specifying the access policies for the domain

domainName String

Name of the domain.

accessPolicies string

IAM policy document specifying the access policies for the domain

domainName string

Name of the domain.

access_policies str

IAM policy document specifying the access policies for the domain

domain_name str

Name of the domain.

accessPolicies String

IAM policy document specifying the access policies for the domain

domainName String

Name of the domain.

Outputs

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

Get an existing DomainPolicy 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?: DomainPolicyState, opts?: CustomResourceOptions): DomainPolicy
@staticmethod
def get(resource_name: str,
        id: str,
        opts: Optional[ResourceOptions] = None,
        access_policies: Optional[str] = None,
        domain_name: Optional[str] = None) -> DomainPolicy
func GetDomainPolicy(ctx *Context, name string, id IDInput, state *DomainPolicyState, opts ...ResourceOption) (*DomainPolicy, error)
public static DomainPolicy Get(string name, Input<string> id, DomainPolicyState? state, CustomResourceOptions? opts = null)
public static DomainPolicy get(String name, Output<String> id, DomainPolicyState 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:
AccessPolicies string

IAM policy document specifying the access policies for the domain

DomainName string

Name of the domain.

AccessPolicies string

IAM policy document specifying the access policies for the domain

DomainName string

Name of the domain.

accessPolicies String

IAM policy document specifying the access policies for the domain

domainName String

Name of the domain.

accessPolicies string

IAM policy document specifying the access policies for the domain

domainName string

Name of the domain.

access_policies str

IAM policy document specifying the access policies for the domain

domain_name str

Name of the domain.

accessPolicies String

IAM policy document specifying the access policies for the domain

domainName String

Name of the domain.

Package Details

Repository
AWS Classic pulumi/pulumi-aws
License
Apache-2.0
Notes

This Pulumi package is based on the aws Terraform Provider.