1. Packages
  2. AWS
  3. API Docs
  4. cloudsearch
  5. DomainServiceAccessPolicy
AWS v6.60.0 published on Tuesday, Nov 19, 2024 by Pulumi

aws.cloudsearch.DomainServiceAccessPolicy

Explore with Pulumi AI

aws logo
AWS v6.60.0 published on Tuesday, Nov 19, 2024 by Pulumi

    Provides an CloudSearch domain service access policy resource.

    The provider waits for the domain service access policy to become Active when applying a configuration.

    Example Usage

    import * as pulumi from "@pulumi/pulumi";
    import * as aws from "@pulumi/aws";
    
    const exampleDomain = new aws.cloudsearch.Domain("example", {name: "example-domain"});
    const example = aws.iam.getPolicyDocument({
        statements: [{
            sid: "search_only",
            effect: "Allow",
            principals: [{
                type: "*",
                identifiers: ["*"],
            }],
            actions: [
                "cloudsearch:search",
                "cloudsearch:document",
            ],
            conditions: [{
                test: "IpAddress",
                variable: "aws:SourceIp",
                values: ["192.0.2.0/32"],
            }],
        }],
    });
    const exampleDomainServiceAccessPolicy = new aws.cloudsearch.DomainServiceAccessPolicy("example", {
        domainName: exampleDomain.id,
        accessPolicy: example.then(example => example.json),
    });
    
    import pulumi
    import pulumi_aws as aws
    
    example_domain = aws.cloudsearch.Domain("example", name="example-domain")
    example = aws.iam.get_policy_document(statements=[{
        "sid": "search_only",
        "effect": "Allow",
        "principals": [{
            "type": "*",
            "identifiers": ["*"],
        }],
        "actions": [
            "cloudsearch:search",
            "cloudsearch:document",
        ],
        "conditions": [{
            "test": "IpAddress",
            "variable": "aws:SourceIp",
            "values": ["192.0.2.0/32"],
        }],
    }])
    example_domain_service_access_policy = aws.cloudsearch.DomainServiceAccessPolicy("example",
        domain_name=example_domain.id,
        access_policy=example.json)
    
    package main
    
    import (
    	"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/cloudsearch"
    	"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 {
    		exampleDomain, err := cloudsearch.NewDomain(ctx, "example", &cloudsearch.DomainArgs{
    			Name: pulumi.String("example-domain"),
    		})
    		if err != nil {
    			return err
    		}
    		example, err := iam.GetPolicyDocument(ctx, &iam.GetPolicyDocumentArgs{
    			Statements: []iam.GetPolicyDocumentStatement{
    				{
    					Sid:    pulumi.StringRef("search_only"),
    					Effect: pulumi.StringRef("Allow"),
    					Principals: []iam.GetPolicyDocumentStatementPrincipal{
    						{
    							Type: "*",
    							Identifiers: []string{
    								"*",
    							},
    						},
    					},
    					Actions: []string{
    						"cloudsearch:search",
    						"cloudsearch:document",
    					},
    					Conditions: []iam.GetPolicyDocumentStatementCondition{
    						{
    							Test:     "IpAddress",
    							Variable: "aws:SourceIp",
    							Values: []string{
    								"192.0.2.0/32",
    							},
    						},
    					},
    				},
    			},
    		}, nil)
    		if err != nil {
    			return err
    		}
    		_, err = cloudsearch.NewDomainServiceAccessPolicy(ctx, "example", &cloudsearch.DomainServiceAccessPolicyArgs{
    			DomainName:   exampleDomain.ID(),
    			AccessPolicy: pulumi.String(example.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 exampleDomain = new Aws.CloudSearch.Domain("example", new()
        {
            Name = "example-domain",
        });
    
        var example = Aws.Iam.GetPolicyDocument.Invoke(new()
        {
            Statements = new[]
            {
                new Aws.Iam.Inputs.GetPolicyDocumentStatementInputArgs
                {
                    Sid = "search_only",
                    Effect = "Allow",
                    Principals = new[]
                    {
                        new Aws.Iam.Inputs.GetPolicyDocumentStatementPrincipalInputArgs
                        {
                            Type = "*",
                            Identifiers = new[]
                            {
                                "*",
                            },
                        },
                    },
                    Actions = new[]
                    {
                        "cloudsearch:search",
                        "cloudsearch:document",
                    },
                    Conditions = new[]
                    {
                        new Aws.Iam.Inputs.GetPolicyDocumentStatementConditionInputArgs
                        {
                            Test = "IpAddress",
                            Variable = "aws:SourceIp",
                            Values = new[]
                            {
                                "192.0.2.0/32",
                            },
                        },
                    },
                },
            },
        });
    
        var exampleDomainServiceAccessPolicy = new Aws.CloudSearch.DomainServiceAccessPolicy("example", new()
        {
            DomainName = exampleDomain.Id,
            AccessPolicy = example.Apply(getPolicyDocumentResult => getPolicyDocumentResult.Json),
        });
    
    });
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.aws.cloudsearch.Domain;
    import com.pulumi.aws.cloudsearch.DomainArgs;
    import com.pulumi.aws.iam.IamFunctions;
    import com.pulumi.aws.iam.inputs.GetPolicyDocumentArgs;
    import com.pulumi.aws.cloudsearch.DomainServiceAccessPolicy;
    import com.pulumi.aws.cloudsearch.DomainServiceAccessPolicyArgs;
    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 exampleDomain = new Domain("exampleDomain", DomainArgs.builder()
                .name("example-domain")
                .build());
    
            final var example = IamFunctions.getPolicyDocument(GetPolicyDocumentArgs.builder()
                .statements(GetPolicyDocumentStatementArgs.builder()
                    .sid("search_only")
                    .effect("Allow")
                    .principals(GetPolicyDocumentStatementPrincipalArgs.builder()
                        .type("*")
                        .identifiers("*")
                        .build())
                    .actions(                
                        "cloudsearch:search",
                        "cloudsearch:document")
                    .conditions(GetPolicyDocumentStatementConditionArgs.builder()
                        .test("IpAddress")
                        .variable("aws:SourceIp")
                        .values("192.0.2.0/32")
                        .build())
                    .build())
                .build());
    
            var exampleDomainServiceAccessPolicy = new DomainServiceAccessPolicy("exampleDomainServiceAccessPolicy", DomainServiceAccessPolicyArgs.builder()
                .domainName(exampleDomain.id())
                .accessPolicy(example.applyValue(getPolicyDocumentResult -> getPolicyDocumentResult.json()))
                .build());
    
        }
    }
    
    resources:
      exampleDomain:
        type: aws:cloudsearch:Domain
        name: example
        properties:
          name: example-domain
      exampleDomainServiceAccessPolicy:
        type: aws:cloudsearch:DomainServiceAccessPolicy
        name: example
        properties:
          domainName: ${exampleDomain.id}
          accessPolicy: ${example.json}
    variables:
      example:
        fn::invoke:
          Function: aws:iam:getPolicyDocument
          Arguments:
            statements:
              - sid: search_only
                effect: Allow
                principals:
                  - type: '*'
                    identifiers:
                      - '*'
                actions:
                  - cloudsearch:search
                  - cloudsearch:document
                conditions:
                  - test: IpAddress
                    variable: aws:SourceIp
                    values:
                      - 192.0.2.0/32
    

    Create DomainServiceAccessPolicy Resource

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

    Constructor syntax

    new DomainServiceAccessPolicy(name: string, args: DomainServiceAccessPolicyArgs, opts?: CustomResourceOptions);
    @overload
    def DomainServiceAccessPolicy(resource_name: str,
                                  args: DomainServiceAccessPolicyArgs,
                                  opts: Optional[ResourceOptions] = None)
    
    @overload
    def DomainServiceAccessPolicy(resource_name: str,
                                  opts: Optional[ResourceOptions] = None,
                                  access_policy: Optional[str] = None,
                                  domain_name: Optional[str] = None)
    func NewDomainServiceAccessPolicy(ctx *Context, name string, args DomainServiceAccessPolicyArgs, opts ...ResourceOption) (*DomainServiceAccessPolicy, error)
    public DomainServiceAccessPolicy(string name, DomainServiceAccessPolicyArgs args, CustomResourceOptions? opts = null)
    public DomainServiceAccessPolicy(String name, DomainServiceAccessPolicyArgs args)
    public DomainServiceAccessPolicy(String name, DomainServiceAccessPolicyArgs args, CustomResourceOptions options)
    
    type: aws:cloudsearch:DomainServiceAccessPolicy
    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 DomainServiceAccessPolicyArgs
    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 DomainServiceAccessPolicyArgs
    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 DomainServiceAccessPolicyArgs
    The arguments to resource properties.
    opts ResourceOption
    Bag of options to control resource's behavior.
    name string
    The unique name of the resource.
    args DomainServiceAccessPolicyArgs
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    name String
    The unique name of the resource.
    args DomainServiceAccessPolicyArgs
    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 domainServiceAccessPolicyResource = new Aws.CloudSearch.DomainServiceAccessPolicy("domainServiceAccessPolicyResource", new()
    {
        AccessPolicy = "string",
        DomainName = "string",
    });
    
    example, err := cloudsearch.NewDomainServiceAccessPolicy(ctx, "domainServiceAccessPolicyResource", &cloudsearch.DomainServiceAccessPolicyArgs{
    	AccessPolicy: pulumi.String("string"),
    	DomainName:   pulumi.String("string"),
    })
    
    var domainServiceAccessPolicyResource = new DomainServiceAccessPolicy("domainServiceAccessPolicyResource", DomainServiceAccessPolicyArgs.builder()
        .accessPolicy("string")
        .domainName("string")
        .build());
    
    domain_service_access_policy_resource = aws.cloudsearch.DomainServiceAccessPolicy("domainServiceAccessPolicyResource",
        access_policy="string",
        domain_name="string")
    
    const domainServiceAccessPolicyResource = new aws.cloudsearch.DomainServiceAccessPolicy("domainServiceAccessPolicyResource", {
        accessPolicy: "string",
        domainName: "string",
    });
    
    type: aws:cloudsearch:DomainServiceAccessPolicy
    properties:
        accessPolicy: string
        domainName: string
    

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

    AccessPolicy string
    The access rules you want to configure. These rules replace any existing rules. See the AWS documentation for details.
    DomainName string
    The CloudSearch domain name the policy applies to.
    AccessPolicy string
    The access rules you want to configure. These rules replace any existing rules. See the AWS documentation for details.
    DomainName string
    The CloudSearch domain name the policy applies to.
    accessPolicy String
    The access rules you want to configure. These rules replace any existing rules. See the AWS documentation for details.
    domainName String
    The CloudSearch domain name the policy applies to.
    accessPolicy string
    The access rules you want to configure. These rules replace any existing rules. See the AWS documentation for details.
    domainName string
    The CloudSearch domain name the policy applies to.
    access_policy str
    The access rules you want to configure. These rules replace any existing rules. See the AWS documentation for details.
    domain_name str
    The CloudSearch domain name the policy applies to.
    accessPolicy String
    The access rules you want to configure. These rules replace any existing rules. See the AWS documentation for details.
    domainName String
    The CloudSearch domain name the policy applies to.

    Outputs

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

    Get an existing DomainServiceAccessPolicy 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?: DomainServiceAccessPolicyState, opts?: CustomResourceOptions): DomainServiceAccessPolicy
    @staticmethod
    def get(resource_name: str,
            id: str,
            opts: Optional[ResourceOptions] = None,
            access_policy: Optional[str] = None,
            domain_name: Optional[str] = None) -> DomainServiceAccessPolicy
    func GetDomainServiceAccessPolicy(ctx *Context, name string, id IDInput, state *DomainServiceAccessPolicyState, opts ...ResourceOption) (*DomainServiceAccessPolicy, error)
    public static DomainServiceAccessPolicy Get(string name, Input<string> id, DomainServiceAccessPolicyState? state, CustomResourceOptions? opts = null)
    public static DomainServiceAccessPolicy get(String name, Output<String> id, DomainServiceAccessPolicyState 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:
    AccessPolicy string
    The access rules you want to configure. These rules replace any existing rules. See the AWS documentation for details.
    DomainName string
    The CloudSearch domain name the policy applies to.
    AccessPolicy string
    The access rules you want to configure. These rules replace any existing rules. See the AWS documentation for details.
    DomainName string
    The CloudSearch domain name the policy applies to.
    accessPolicy String
    The access rules you want to configure. These rules replace any existing rules. See the AWS documentation for details.
    domainName String
    The CloudSearch domain name the policy applies to.
    accessPolicy string
    The access rules you want to configure. These rules replace any existing rules. See the AWS documentation for details.
    domainName string
    The CloudSearch domain name the policy applies to.
    access_policy str
    The access rules you want to configure. These rules replace any existing rules. See the AWS documentation for details.
    domain_name str
    The CloudSearch domain name the policy applies to.
    accessPolicy String
    The access rules you want to configure. These rules replace any existing rules. See the AWS documentation for details.
    domainName String
    The CloudSearch domain name the policy applies to.

    Import

    Using pulumi import, import CloudSearch domain service access policies using the domain name. For example:

    $ pulumi import aws:cloudsearch/domainServiceAccessPolicy:DomainServiceAccessPolicy example example-domain
    

    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
    AWS v6.60.0 published on Tuesday, Nov 19, 2024 by Pulumi