1. Packages
  2. AWS
  3. API Docs
  4. oam
  5. SinkPolicy
AWS v6.76.0 published on Tuesday, Apr 8, 2025 by Pulumi

aws.oam.SinkPolicy

Explore with Pulumi AI

Resource for managing an AWS CloudWatch Observability Access Manager Sink Policy.

Example Usage

Basic Usage

import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";

const example = new aws.oam.Sink("example", {name: "ExampleSink"});
const exampleSinkPolicy = new aws.oam.SinkPolicy("example", {
    sinkIdentifier: example.arn,
    policy: JSON.stringify({
        Version: "2012-10-17",
        Statement: [{
            Action: [
                "oam:CreateLink",
                "oam:UpdateLink",
            ],
            Effect: "Allow",
            Resource: "*",
            Principal: {
                AWS: [
                    "1111111111111",
                    "222222222222",
                ],
            },
            Condition: {
                "ForAllValues:StringEquals": {
                    "oam:ResourceTypes": [
                        "AWS::CloudWatch::Metric",
                        "AWS::Logs::LogGroup",
                    ],
                },
            },
        }],
    }),
});
Copy
import pulumi
import json
import pulumi_aws as aws

example = aws.oam.Sink("example", name="ExampleSink")
example_sink_policy = aws.oam.SinkPolicy("example",
    sink_identifier=example.arn,
    policy=json.dumps({
        "Version": "2012-10-17",
        "Statement": [{
            "Action": [
                "oam:CreateLink",
                "oam:UpdateLink",
            ],
            "Effect": "Allow",
            "Resource": "*",
            "Principal": {
                "AWS": [
                    "1111111111111",
                    "222222222222",
                ],
            },
            "Condition": {
                "ForAllValues:StringEquals": {
                    "oam:ResourceTypes": [
                        "AWS::CloudWatch::Metric",
                        "AWS::Logs::LogGroup",
                    ],
                },
            },
        }],
    }))
Copy
package main

import (
	"encoding/json"

	"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/oam"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		example, err := oam.NewSink(ctx, "example", &oam.SinkArgs{
			Name: pulumi.String("ExampleSink"),
		})
		if err != nil {
			return err
		}
		tmpJSON0, err := json.Marshal(map[string]interface{}{
			"Version": "2012-10-17",
			"Statement": []map[string]interface{}{
				map[string]interface{}{
					"Action": []string{
						"oam:CreateLink",
						"oam:UpdateLink",
					},
					"Effect":   "Allow",
					"Resource": "*",
					"Principal": map[string]interface{}{
						"AWS": []string{
							"1111111111111",
							"222222222222",
						},
					},
					"Condition": map[string]interface{}{
						"ForAllValues:StringEquals": map[string]interface{}{
							"oam:ResourceTypes": []string{
								"AWS::CloudWatch::Metric",
								"AWS::Logs::LogGroup",
							},
						},
					},
				},
			},
		})
		if err != nil {
			return err
		}
		json0 := string(tmpJSON0)
		_, err = oam.NewSinkPolicy(ctx, "example", &oam.SinkPolicyArgs{
			SinkIdentifier: example.Arn,
			Policy:         pulumi.String(json0),
		})
		if err != nil {
			return err
		}
		return nil
	})
}
Copy
using System.Collections.Generic;
using System.Linq;
using System.Text.Json;
using Pulumi;
using Aws = Pulumi.Aws;

return await Deployment.RunAsync(() => 
{
    var example = new Aws.Oam.Sink("example", new()
    {
        Name = "ExampleSink",
    });

    var exampleSinkPolicy = new Aws.Oam.SinkPolicy("example", new()
    {
        SinkIdentifier = example.Arn,
        Policy = JsonSerializer.Serialize(new Dictionary<string, object?>
        {
            ["Version"] = "2012-10-17",
            ["Statement"] = new[]
            {
                new Dictionary<string, object?>
                {
                    ["Action"] = new[]
                    {
                        "oam:CreateLink",
                        "oam:UpdateLink",
                    },
                    ["Effect"] = "Allow",
                    ["Resource"] = "*",
                    ["Principal"] = new Dictionary<string, object?>
                    {
                        ["AWS"] = new[]
                        {
                            "1111111111111",
                            "222222222222",
                        },
                    },
                    ["Condition"] = new Dictionary<string, object?>
                    {
                        ["ForAllValues:StringEquals"] = new Dictionary<string, object?>
                        {
                            ["oam:ResourceTypes"] = new[]
                            {
                                "AWS::CloudWatch::Metric",
                                "AWS::Logs::LogGroup",
                            },
                        },
                    },
                },
            },
        }),
    });

});
Copy
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.aws.oam.Sink;
import com.pulumi.aws.oam.SinkArgs;
import com.pulumi.aws.oam.SinkPolicy;
import com.pulumi.aws.oam.SinkPolicyArgs;
import static com.pulumi.codegen.internal.Serialization.*;
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 Sink("example", SinkArgs.builder()
            .name("ExampleSink")
            .build());

        var exampleSinkPolicy = new SinkPolicy("exampleSinkPolicy", SinkPolicyArgs.builder()
            .sinkIdentifier(example.arn())
            .policy(serializeJson(
                jsonObject(
                    jsonProperty("Version", "2012-10-17"),
                    jsonProperty("Statement", jsonArray(jsonObject(
                        jsonProperty("Action", jsonArray(
                            "oam:CreateLink", 
                            "oam:UpdateLink"
                        )),
                        jsonProperty("Effect", "Allow"),
                        jsonProperty("Resource", "*"),
                        jsonProperty("Principal", jsonObject(
                            jsonProperty("AWS", jsonArray(
                                "1111111111111", 
                                "222222222222"
                            ))
                        )),
                        jsonProperty("Condition", jsonObject(
                            jsonProperty("ForAllValues:StringEquals", jsonObject(
                                jsonProperty("oam:ResourceTypes", jsonArray(
                                    "AWS::CloudWatch::Metric", 
                                    "AWS::Logs::LogGroup"
                                ))
                            ))
                        ))
                    )))
                )))
            .build());

    }
}
Copy
resources:
  example:
    type: aws:oam:Sink
    properties:
      name: ExampleSink
  exampleSinkPolicy:
    type: aws:oam:SinkPolicy
    name: example
    properties:
      sinkIdentifier: ${example.arn}
      policy:
        fn::toJSON:
          Version: 2012-10-17
          Statement:
            - Action:
                - oam:CreateLink
                - oam:UpdateLink
              Effect: Allow
              Resource: '*'
              Principal:
                AWS:
                  - '1111111111111'
                  - '222222222222'
              Condition:
                ForAllValues:StringEquals:
                  oam:ResourceTypes:
                    - AWS::CloudWatch::Metric
                    - AWS::Logs::LogGroup
Copy

Create SinkPolicy Resource

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

Constructor syntax

new SinkPolicy(name: string, args: SinkPolicyArgs, opts?: CustomResourceOptions);
@overload
def SinkPolicy(resource_name: str,
               args: SinkPolicyArgs,
               opts: Optional[ResourceOptions] = None)

@overload
def SinkPolicy(resource_name: str,
               opts: Optional[ResourceOptions] = None,
               policy: Optional[str] = None,
               sink_identifier: Optional[str] = None)
func NewSinkPolicy(ctx *Context, name string, args SinkPolicyArgs, opts ...ResourceOption) (*SinkPolicy, error)
public SinkPolicy(string name, SinkPolicyArgs args, CustomResourceOptions? opts = null)
public SinkPolicy(String name, SinkPolicyArgs args)
public SinkPolicy(String name, SinkPolicyArgs args, CustomResourceOptions options)
type: aws:oam:SinkPolicy
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. SinkPolicyArgs
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. SinkPolicyArgs
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. SinkPolicyArgs
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. SinkPolicyArgs
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. SinkPolicyArgs
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 sinkPolicyResource = new Aws.Oam.SinkPolicy("sinkPolicyResource", new()
{
    Policy = "string",
    SinkIdentifier = "string",
});
Copy
example, err := oam.NewSinkPolicy(ctx, "sinkPolicyResource", &oam.SinkPolicyArgs{
	Policy:         pulumi.String("string"),
	SinkIdentifier: pulumi.String("string"),
})
Copy
var sinkPolicyResource = new SinkPolicy("sinkPolicyResource", SinkPolicyArgs.builder()
    .policy("string")
    .sinkIdentifier("string")
    .build());
Copy
sink_policy_resource = aws.oam.SinkPolicy("sinkPolicyResource",
    policy="string",
    sink_identifier="string")
Copy
const sinkPolicyResource = new aws.oam.SinkPolicy("sinkPolicyResource", {
    policy: "string",
    sinkIdentifier: "string",
});
Copy
type: aws:oam:SinkPolicy
properties:
    policy: string
    sinkIdentifier: string
Copy

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

Policy This property is required. string
JSON policy to use. If you are updating an existing policy, the entire existing policy is replaced by what you specify here.
SinkIdentifier
This property is required.
Changes to this property will trigger replacement.
string
ARN of the sink to attach this policy to.
Policy This property is required. string
JSON policy to use. If you are updating an existing policy, the entire existing policy is replaced by what you specify here.
SinkIdentifier
This property is required.
Changes to this property will trigger replacement.
string
ARN of the sink to attach this policy to.
policy This property is required. String
JSON policy to use. If you are updating an existing policy, the entire existing policy is replaced by what you specify here.
sinkIdentifier
This property is required.
Changes to this property will trigger replacement.
String
ARN of the sink to attach this policy to.
policy This property is required. string
JSON policy to use. If you are updating an existing policy, the entire existing policy is replaced by what you specify here.
sinkIdentifier
This property is required.
Changes to this property will trigger replacement.
string
ARN of the sink to attach this policy to.
policy This property is required. str
JSON policy to use. If you are updating an existing policy, the entire existing policy is replaced by what you specify here.
sink_identifier
This property is required.
Changes to this property will trigger replacement.
str
ARN of the sink to attach this policy to.
policy This property is required. String
JSON policy to use. If you are updating an existing policy, the entire existing policy is replaced by what you specify here.
sinkIdentifier
This property is required.
Changes to this property will trigger replacement.
String
ARN of the sink to attach this policy to.

Outputs

All input properties are implicitly available as output properties. Additionally, the SinkPolicy resource produces the following output properties:

Arn string
ARN of the Sink.
Id string
The provider-assigned unique ID for this managed resource.
SinkId string
ID string that AWS generated as part of the sink ARN.
Arn string
ARN of the Sink.
Id string
The provider-assigned unique ID for this managed resource.
SinkId string
ID string that AWS generated as part of the sink ARN.
arn String
ARN of the Sink.
id String
The provider-assigned unique ID for this managed resource.
sinkId String
ID string that AWS generated as part of the sink ARN.
arn string
ARN of the Sink.
id string
The provider-assigned unique ID for this managed resource.
sinkId string
ID string that AWS generated as part of the sink ARN.
arn str
ARN of the Sink.
id str
The provider-assigned unique ID for this managed resource.
sink_id str
ID string that AWS generated as part of the sink ARN.
arn String
ARN of the Sink.
id String
The provider-assigned unique ID for this managed resource.
sinkId String
ID string that AWS generated as part of the sink ARN.

Look up Existing SinkPolicy Resource

Get an existing SinkPolicy 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?: SinkPolicyState, opts?: CustomResourceOptions): SinkPolicy
@staticmethod
def get(resource_name: str,
        id: str,
        opts: Optional[ResourceOptions] = None,
        arn: Optional[str] = None,
        policy: Optional[str] = None,
        sink_id: Optional[str] = None,
        sink_identifier: Optional[str] = None) -> SinkPolicy
func GetSinkPolicy(ctx *Context, name string, id IDInput, state *SinkPolicyState, opts ...ResourceOption) (*SinkPolicy, error)
public static SinkPolicy Get(string name, Input<string> id, SinkPolicyState? state, CustomResourceOptions? opts = null)
public static SinkPolicy get(String name, Output<String> id, SinkPolicyState state, CustomResourceOptions options)
resources:  _:    type: aws:oam:SinkPolicy    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:
Arn string
ARN of the Sink.
Policy string
JSON policy to use. If you are updating an existing policy, the entire existing policy is replaced by what you specify here.
SinkId string
ID string that AWS generated as part of the sink ARN.
SinkIdentifier Changes to this property will trigger replacement. string
ARN of the sink to attach this policy to.
Arn string
ARN of the Sink.
Policy string
JSON policy to use. If you are updating an existing policy, the entire existing policy is replaced by what you specify here.
SinkId string
ID string that AWS generated as part of the sink ARN.
SinkIdentifier Changes to this property will trigger replacement. string
ARN of the sink to attach this policy to.
arn String
ARN of the Sink.
policy String
JSON policy to use. If you are updating an existing policy, the entire existing policy is replaced by what you specify here.
sinkId String
ID string that AWS generated as part of the sink ARN.
sinkIdentifier Changes to this property will trigger replacement. String
ARN of the sink to attach this policy to.
arn string
ARN of the Sink.
policy string
JSON policy to use. If you are updating an existing policy, the entire existing policy is replaced by what you specify here.
sinkId string
ID string that AWS generated as part of the sink ARN.
sinkIdentifier Changes to this property will trigger replacement. string
ARN of the sink to attach this policy to.
arn str
ARN of the Sink.
policy str
JSON policy to use. If you are updating an existing policy, the entire existing policy is replaced by what you specify here.
sink_id str
ID string that AWS generated as part of the sink ARN.
sink_identifier Changes to this property will trigger replacement. str
ARN of the sink to attach this policy to.
arn String
ARN of the Sink.
policy String
JSON policy to use. If you are updating an existing policy, the entire existing policy is replaced by what you specify here.
sinkId String
ID string that AWS generated as part of the sink ARN.
sinkIdentifier Changes to this property will trigger replacement. String
ARN of the sink to attach this policy to.

Import

Using pulumi import, import CloudWatch Observability Access Manager Sink Policy using the sink_identifier. For example:

$ pulumi import aws:oam/sinkPolicy:SinkPolicy example arn:aws:oam:us-west-2:123456789012:sink/sink-id
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.