ResourcePolicy class
Resource for managing an AWS OpenSearch Ingestion Resource Policy.
Example Usage
Basic Usage
import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";
const current = aws.getCallerIdentity({});
const examplePipeline = new aws.opensearchingest.Pipeline("example", {
pipelineName: "example",
pipelineConfigurationBody: current.then(current => `version: \"2\"
example-pipeline:
source:
http:
path: \"/example\"
sink:
- s3:
aws:
sts_role_arn: \"arn:aws:iam::${current.accountId}:role/Example\"
region: \"us-east-1\"
bucket: \"example\"
threshold:
event_collect_timeout: \"60s\"
codec:
ndjson:
`),
maxUnits: 1,
minUnits: 1,
});
const example = new aws.opensearchingest.ResourcePolicy("example", {
resourceArn: examplePipeline.pipelineArn,
policy: pulumi.jsonStringify({
Version: "2012-10-17",
Statement: [{
Effect: "Allow",
Principal: {
AWS: current.then(current => `arn:aws:iam::${current.accountId}:root`),
},
Action: "osis:CreatePipelineEndpoint",
Resource: examplePipeline.pipelineArn,
}],
}),
});
import pulumi
import json
import pulumi_aws as aws
current = aws.get_caller_identity()
example_pipeline = aws.opensearchingest.Pipeline("example",
pipeline_name="example",
pipeline_configuration_body=f"""version: \"2\"
example-pipeline:
source:
http:
path: \"/example\"
sink:
- s3:
aws:
sts_role_arn: \"arn:aws:iam::{current.account_id}:role/Example\"
region: \"us-east-1\"
bucket: \"example\"
threshold:
event_collect_timeout: \"60s\"
codec:
ndjson:
""",
max_units=1,
min_units=1)
example = aws.opensearchingest.ResourcePolicy("example",
resource_arn=example_pipeline.pipeline_arn,
policy=pulumi.Output.json_dumps({
"Version": "2012-10-17",
"Statement": [{
"Effect": "Allow",
"Principal": {
"AWS": f"arn:aws:iam::{current.account_id}:root",
},
"Action": "osis:CreatePipelineEndpoint",
"Resource": example_pipeline.pipeline_arn,
}],
}))
using System.Collections.Generic;
using System.Linq;
using System.Text.Json;
using Pulumi;
using Aws = Pulumi.Aws;
return await Deployment.RunAsync(() =>
{
var current = Aws.GetCallerIdentity.Invoke();
var examplePipeline = new Aws.OpenSearchIngest.Pipeline("example", new()
{
PipelineName = "example",
PipelineConfigurationBody = @$"version: \""2\""
example-pipeline:
source:
http:
path: \""/example\""
sink:
- s3:
aws:
sts_role_arn: \""arn:aws:iam::{current.Apply(getCallerIdentityResult => getCallerIdentityResult.AccountId)}:role/Example\""
region: \""us-east-1\""
bucket: \""example\""
threshold:
event_collect_timeout: \""60s\""
codec:
ndjson:
",
MaxUnits = 1,
MinUnits = 1,
});
var example = new Aws.OpenSearchIngest.ResourcePolicy("example", new()
{
ResourceArn = examplePipeline.PipelineArn,
Policy = Output.JsonSerialize(Output.Create(new Dictionary<string, object?>
{
["Version"] = "2012-10-17",
["Statement"] = new[]
{
new Dictionary<string, object?>
{
["Effect"] = "Allow",
["Principal"] = new Dictionary<string, object?>
{
["AWS"] = $"arn:aws:iam::{current.Apply(getCallerIdentityResult => getCallerIdentityResult.AccountId)}:root",
},
["Action"] = "osis:CreatePipelineEndpoint",
["Resource"] = examplePipeline.PipelineArn,
},
},
})),
});
});
package main
import (
"encoding/json"
"fmt"
"github.com/pulumi/pulumi-aws/sdk/v7/go/aws"
"github.com/pulumi/pulumi-aws/sdk/v7/go/aws/opensearchingest"
"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
}
examplePipeline, err := opensearchingest.NewPipeline(ctx, "example", &opensearchingest.PipelineArgs{
PipelineName: pulumi.String("example"),
PipelineConfigurationBody: pulumi.Sprintf(`version: \"2\"
example-pipeline:
source:
http:
path: \"/example\"
sink:
- s3:
aws:
sts_role_arn: \"arn:aws:iam::%v:role/Example\"
region: \"us-east-1\"
bucket: \"example\"
threshold:
event_collect_timeout: \"60s\"
codec:
ndjson:
`, current.AccountId),
MaxUnits: pulumi.Int(1),
MinUnits: pulumi.Int(1),
})
if err != nil {
return err
}
_, err = opensearchingest.NewResourcePolicy(ctx, "example", &opensearchingest.ResourcePolicyArgs{
ResourceArn: examplePipeline.PipelineArn,
Policy: examplePipeline.PipelineArn.ApplyT(func(pipelineArn string) (pulumi.String, error) {
var _zero pulumi.String
tmpJSON0, err := json.Marshal(map[string]interface{}{
"Version": "2012-10-17",
"Statement": []map[string]interface{}{
map[string]interface{}{
"Effect": "Allow",
"Principal": map[string]string{
"AWS": fmt.Sprintf("arn:aws:iam::%v:root", current.AccountId),
},
"Action": "osis:CreatePipelineEndpoint",
"Resource": pipelineArn,
},
},
})
if err != nil {
return _zero, err
}
json0 := string(tmpJSON0)
return pulumi.String(json0), nil
}).(pulumi.StringOutput),
})
if err != nil {
return err
}
return nil
})
}
pulumi {
required_providers {
aws = {
source = "pulumi/aws"
}
}
}
data "aws_getcalleridentity" "current" {
}
resource "aws_opensearchingest_resourcepolicy" "example" {
resource_arn = aws_opensearchingest_pipeline.example.pipeline_arn
policy = jsonencode({
"Version" = "2012-10-17"
"Statement" = [{
"Effect" = "Allow"
"Principal" = {
"AWS" ="arn:aws:iam::${data.aws_getcalleridentity.current.account_id}:root"
}
"Action" = "osis:CreatePipelineEndpoint"
"Resource" = aws_opensearchingest_pipeline.example.pipeline_arn
}]
})
}
resource "aws_opensearchingest_pipeline" "example" {
pipeline_name = "example"
pipeline_configuration_body ="version: \"2\"
example-pipeline:
source:
http:
path: \"/example\"
sink:
- s3:
aws:
sts_role_arn: \"arn:aws:iam::${data.aws_getcalleridentity.current.account_id}:role/Example\"
region: \"us-east-1\"
bucket: \"example\"
threshold:
event_collect_timeout: \"60s\"
codec:
ndjson:
"
max_units = 1
min_units = 1
}
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.opensearchingest.Pipeline;
import com.pulumi.aws.opensearchingest.PipelineArgs;
import com.pulumi.aws.opensearchingest.ResourcePolicy;
import com.pulumi.aws.opensearchingest.ResourcePolicyArgs;
import static com.pulumi.codegen.internal.Serialization.*;
import java.util.ArrayList;
import java.util.Arrays;
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());
var examplePipeline = new Pipeline("examplePipeline", PipelineArgs.builder()
.pipelineName("example")
.pipelineConfigurationBody("""
version: \"2\"
example-pipeline:
source:
http:
path: \"/example\"
sink:
- s3:
aws:
sts_role_arn: \"arn:aws:iam::%s:role/Example\"
region: \"us-east-1\"
bucket: \"example\"
threshold:
event_collect_timeout: \"60s\"
codec:
ndjson:
", current.accountId()))
.maxUnits(1)
.minUnits(1)
.build());
var example = new ResourcePolicy("example", ResourcePolicyArgs.builder()
.resourceArn(examplePipeline.pipelineArn())
.policy(examplePipeline.pipelineArn().applyValue(_pipelineArn -> serializeJson(
jsonObject(
jsonProperty("Version", "2012-10-17"),
jsonProperty("Statement", jsonArray(jsonObject(
jsonProperty("Effect", "Allow"),
jsonProperty("Principal", jsonObject(
jsonProperty("AWS", String.format("arn:aws:iam::%s:root", current.accountId()))
)),
jsonProperty("Action", "osis:CreatePipelineEndpoint"),
jsonProperty("Resource", _pipelineArn)
)))
))))
.build());
}
}
resources:
example:
type: aws:opensearchingest:ResourcePolicy
properties:
resourceArn: ${examplePipeline.pipelineArn}
policy:
fn::toJSON:
Version: 2012-10-17
Statement:
- Effect: Allow
Principal:
AWS: arn:aws:iam::${current.accountId}:root
Action: osis:CreatePipelineEndpoint
Resource: ${examplePipeline.pipelineArn}
examplePipeline:
type: aws:opensearchingest:Pipeline
name: example
properties:
pipelineName: example
pipelineConfigurationBody: |
version: \"2\"
example-pipeline:
source:
http:
path: \"/example\"
sink:
- s3:
aws:
sts_role_arn: \"arn:aws:iam::${current.accountId}:role/Example\"
region: \"us-east-1\"
bucket: \"example\"
threshold:
event_collect_timeout: \"60s\"
codec:
ndjson:
maxUnits: 1
minUnits: 1
variables:
current:
fn::invoke:
function: aws:getCallerIdentity
arguments: {}
Import
Identity Schema
Required
resourceArn(String) ARN of the resource the policy is attached to.
Using pulumi import, import OpenSearch Ingestion Resource Policy using the resourceArn. For example:
$ pulumi import aws:opensearchingest/resourcePolicy:ResourcePolicy example arn:aws:osis:us-east-1:123456789012:pipeline/example
Constructors
- ResourcePolicy(String name, {ResourcePolicyArgs? args, CustomResourceOptions? options})
-
Creates a new ResourcePolicy.
nameThe Pulumi resource name.argsArguments used to configure this ResourcePolicy. The set of arguments for ResourcePolicy.optionsResource options controlling this resource's behavior. - ResourcePolicy.reference(String urn)
- Creates a typed reference to an existing ResourcePolicy resource.
Properties
-
childResources
→ Set<
Resource> -
finalinherited
-
completionSources
↔ Map<
String, IOutputCompletionSource> -
latefinalinherited
- hashCode → int
-
The hash code for this object.
no setterinherited
-
id
↔ Output<
String> -
getter/setter pairinherited
- isCustom → bool
-
Returns whether this resource is provider-managed.
no setterinherited
- isProtected → bool
-
Returns whether this resource is protected from deletion.
no setterinherited
- isRemote → bool
-
Whether this resource is registered as remote.
no setterinherited
- isResourceReference → bool
-
Whether this instance represents a resource value returned over RPC.
finalinherited
-
policy
↔ Output<
String> -
JSON-formatted policy to attach to the resource.
latefinal
-
region
↔ Output<
String> -
Region where this resource will be managed. Defaults to the Region set in the provider configuration.
latefinal
-
resourceArn
↔ Output<
String> -
ARN of the resource to attach the policy to.
latefinal
-
resourceTransforms
→ List<
ResourceTransform> -
Inherited/explicit async transforms.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
-
transformations
→ List<
ResourceTransformation> -
Inherited/explicit legacy transformations.
no setterinherited
-
urn
↔ Output<
String> -
latefinalinherited
Methods
-
failId(
Object error) → void -
Completes this resource ID with an error when registration fails.
inherited
-
failOutputs(
Object error) → void -
Completes all output properties with
error.inherited -
failUrn(
Object error) → void -
Completes this resource URN with an error when registration fails.
inherited
-
getProvider(
String moduleMember) → ProviderResource? -
Returns provider for
moduleMember's package, if configured.inherited -
getResourceName(
) → String -
Returns this resource's logical name.
inherited
-
getResourceType(
) → String -
Returns this resource's Pulumi type token.
inherited
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
registerOutput<
T> (String propertyName, {Object? decoder(Object?)?, bool isSecret = false}) → Output< T> -
Registers a dynamic output property for this resource.
inherited
-
resolveId(
String? value, {required bool isKnown}) → void -
Resolves the provider-assigned ID for this resource.
inherited
-
resolveOutputs(
Struct outputs) → void -
Resolves all output properties from a monitor response payload.
inherited
-
resolveUrn(
String value) → void -
Resolves this resource's URN once assigned by the engine.
inherited
-
serializeProperties(
Map< String, dynamic> properties) → Future<Struct> -
Serializes resource properties for RPC transmission.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Methods
-
get(
String name, Input< String> id, {ResourcePolicyState? state, CustomResourceOptions? options}) → ResourcePolicy -
Gets an existing ResourcePolicy resource's state with the given
nameandid.