aws.opensearch.DomainPolicy
Explore with Pulumi AI
Allows setting policy to an OpenSearch domain while referencing domain attributes (e.g., ARN).
Example Usage
import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";
const example = new aws.opensearch.Domain("example", {
domainName: "tf-test",
engineVersion: "OpenSearch_1.1",
});
const main = aws.iam.getPolicyDocumentOutput({
statements: [{
effect: "Allow",
principals: [{
type: "*",
identifiers: ["*"],
}],
actions: ["es:*"],
resources: [pulumi.interpolate`${example.arn}/*`],
conditions: [{
test: "IpAddress",
variable: "aws:SourceIp",
values: ["127.0.0.1/32"],
}],
}],
});
const mainDomainPolicy = new aws.opensearch.DomainPolicy("main", {
domainName: example.domainName,
accessPolicies: main.apply(main => main.json),
});
import pulumi
import pulumi_aws as aws
example = aws.opensearch.Domain("example",
domain_name="tf-test",
engine_version="OpenSearch_1.1")
main = aws.iam.get_policy_document_output(statements=[{
"effect": "Allow",
"principals": [{
"type": "*",
"identifiers": ["*"],
}],
"actions": ["es:*"],
"resources": [example.arn.apply(lambda arn: f"{arn}/*")],
"conditions": [{
"test": "IpAddress",
"variable": "aws:SourceIp",
"values": ["127.0.0.1/32"],
}],
}])
main_domain_policy = aws.opensearch.DomainPolicy("main",
domain_name=example.domain_name,
access_policies=main.json)
package main
import (
"fmt"
"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/iam"
"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/opensearch"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
example, err := opensearch.NewDomain(ctx, "example", &opensearch.DomainArgs{
DomainName: pulumi.String("tf-test"),
EngineVersion: pulumi.String("OpenSearch_1.1"),
})
if err != nil {
return err
}
main := iam.GetPolicyDocumentOutput(ctx, iam.GetPolicyDocumentOutputArgs{
Statements: iam.GetPolicyDocumentStatementArray{
&iam.GetPolicyDocumentStatementArgs{
Effect: pulumi.String("Allow"),
Principals: iam.GetPolicyDocumentStatementPrincipalArray{
&iam.GetPolicyDocumentStatementPrincipalArgs{
Type: pulumi.String("*"),
Identifiers: pulumi.StringArray{
pulumi.String("*"),
},
},
},
Actions: pulumi.StringArray{
pulumi.String("es:*"),
},
Resources: pulumi.StringArray{
example.Arn.ApplyT(func(arn string) (string, error) {
return fmt.Sprintf("%v/*", arn), nil
}).(pulumi.StringOutput),
},
Conditions: iam.GetPolicyDocumentStatementConditionArray{
&iam.GetPolicyDocumentStatementConditionArgs{
Test: pulumi.String("IpAddress"),
Variable: pulumi.String("aws:SourceIp"),
Values: pulumi.StringArray{
pulumi.String("127.0.0.1/32"),
},
},
},
},
},
}, nil)
_, err = opensearch.NewDomainPolicy(ctx, "main", &opensearch.DomainPolicyArgs{
DomainName: example.DomainName,
AccessPolicies: pulumi.String(main.ApplyT(func(main iam.GetPolicyDocumentResult) (*string, error) {
return &main.Json, nil
}).(pulumi.StringPtrOutput)),
})
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 = new Aws.OpenSearch.Domain("example", new()
{
DomainName = "tf-test",
EngineVersion = "OpenSearch_1.1",
});
var main = Aws.Iam.GetPolicyDocument.Invoke(new()
{
Statements = new[]
{
new Aws.Iam.Inputs.GetPolicyDocumentStatementInputArgs
{
Effect = "Allow",
Principals = new[]
{
new Aws.Iam.Inputs.GetPolicyDocumentStatementPrincipalInputArgs
{
Type = "*",
Identifiers = new[]
{
"*",
},
},
},
Actions = new[]
{
"es:*",
},
Resources = new[]
{
$"{example.Arn}/*",
},
Conditions = new[]
{
new Aws.Iam.Inputs.GetPolicyDocumentStatementConditionInputArgs
{
Test = "IpAddress",
Variable = "aws:SourceIp",
Values = new[]
{
"127.0.0.1/32",
},
},
},
},
},
});
var mainDomainPolicy = new Aws.OpenSearch.DomainPolicy("main", new()
{
DomainName = example.DomainName,
AccessPolicies = main.Apply(getPolicyDocumentResult => getPolicyDocumentResult.Json),
});
});
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()
.domainName("tf-test")
.engineVersion("OpenSearch_1.1")
.build());
final var main = IamFunctions.getPolicyDocument(GetPolicyDocumentArgs.builder()
.statements(GetPolicyDocumentStatementArgs.builder()
.effect("Allow")
.principals(GetPolicyDocumentStatementPrincipalArgs.builder()
.type("*")
.identifiers("*")
.build())
.actions("es:*")
.resources(example.arn().applyValue(arn -> String.format("%s/*", arn)))
.conditions(GetPolicyDocumentStatementConditionArgs.builder()
.test("IpAddress")
.variable("aws:SourceIp")
.values("127.0.0.1/32")
.build())
.build())
.build());
var mainDomainPolicy = new DomainPolicy("mainDomainPolicy", DomainPolicyArgs.builder()
.domainName(example.domainName())
.accessPolicies(main.applyValue(getPolicyDocumentResult -> getPolicyDocumentResult).applyValue(main -> main.applyValue(getPolicyDocumentResult -> getPolicyDocumentResult.json())))
.build());
}
}
resources:
example:
type: aws:opensearch:Domain
properties:
domainName: tf-test
engineVersion: OpenSearch_1.1
mainDomainPolicy:
type: aws:opensearch:DomainPolicy
name: main
properties:
domainName: ${example.domainName}
accessPolicies: ${main.json}
variables:
main:
fn::invoke:
Function: aws:iam:getPolicyDocument
Arguments:
statements:
- effect: Allow
principals:
- type: '*'
identifiers:
- '*'
actions:
- es:*
resources:
- ${example.arn}/*
conditions:
- test: IpAddress
variable: aws:SourceIp
values:
- 127.0.0.1/32
Create DomainPolicy Resource
Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.
Constructor syntax
new DomainPolicy(name: string, args: DomainPolicyArgs, opts?: CustomResourceOptions);
@overload
def DomainPolicy(resource_name: str,
args: DomainPolicyArgs,
opts: Optional[ResourceOptions] = None)
@overload
def DomainPolicy(resource_name: str,
opts: Optional[ResourceOptions] = None,
access_policies: Optional[str] = None,
domain_name: Optional[str] = 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.
Parameters
- 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.
Constructor example
The following reference example uses placeholder values for all input properties.
var awsDomainPolicyResource = new Aws.OpenSearch.DomainPolicy("awsDomainPolicyResource", new()
{
AccessPolicies = "string",
DomainName = "string",
});
example, err := opensearch.NewDomainPolicy(ctx, "awsDomainPolicyResource", &opensearch.DomainPolicyArgs{
AccessPolicies: pulumi.String("string"),
DomainName: pulumi.String("string"),
})
var awsDomainPolicyResource = new DomainPolicy("awsDomainPolicyResource", DomainPolicyArgs.builder()
.accessPolicies("string")
.domainName("string")
.build());
aws_domain_policy_resource = aws.opensearch.DomainPolicy("awsDomainPolicyResource",
access_policies="string",
domain_name="string")
const awsDomainPolicyResource = new aws.opensearch.DomainPolicy("awsDomainPolicyResource", {
accessPolicies: "string",
domainName: "string",
});
type: aws:opensearch:DomainPolicy
properties:
accessPolicies: string
domainName: string
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
In Python, inputs that are objects can be passed either as argument classes or as dictionary literals.
The DomainPolicy resource accepts the following input properties:
- Access
Policies string - IAM policy document specifying the access policies for the domain
- Domain
Name string - Name of the domain.
- Access
Policies string - IAM policy document specifying the access policies for the domain
- Domain
Name string - Name of the domain.
- access
Policies String - IAM policy document specifying the access policies for the domain
- domain
Name String - Name of the domain.
- access
Policies string - IAM policy document specifying the access policies for the domain
- domain
Name 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.
- access
Policies String - IAM policy document specifying the access policies for the domain
- domain
Name 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.
- Access
Policies string - IAM policy document specifying the access policies for the domain
- Domain
Name string - Name of the domain.
- Access
Policies string - IAM policy document specifying the access policies for the domain
- Domain
Name string - Name of the domain.
- access
Policies String - IAM policy document specifying the access policies for the domain
- domain
Name String - Name of the domain.
- access
Policies string - IAM policy document specifying the access policies for the domain
- domain
Name 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.
- access
Policies String - IAM policy document specifying the access policies for the domain
- domain
Name 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.