1. Packages
  2. AWS Classic
  3. API Docs
  4. oam
  5. SinkPolicy

Try AWS Native preview for resources not in the classic version.

AWS Classic v6.42.0 published on Wednesday, Jun 26, 2024 by Pulumi

aws.oam.SinkPolicy

Explore with Pulumi AI

aws logo

Try AWS Native preview for resources not in the classic version.

AWS Classic v6.42.0 published on Wednesday, Jun 26, 2024 by Pulumi

    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.id,
        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",
                        ],
                    },
                },
            }],
        }),
    });
    
    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.id,
        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",
                        ],
                    },
                },
            }],
        }))
    
    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.ID(),
    			Policy:         pulumi.String(json0),
    		})
    		if err != nil {
    			return err
    		}
    		return nil
    	})
    }
    
    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.Id,
            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",
                                },
                            },
                        },
                    },
                },
            }),
        });
    
    });
    
    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.id())
                .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());
    
        }
    }
    
    resources:
      example:
        type: aws:oam:Sink
        properties:
          name: ExampleSink
      exampleSinkPolicy:
        type: aws:oam:SinkPolicy
        name: example
        properties:
          sinkIdentifier: ${example.id}
          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
    

    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 string
    The unique name of the resource.
    args SinkPolicyArgs
    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 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 string
    The unique name of the resource.
    args SinkPolicyArgs
    The arguments to resource properties.
    opts ResourceOption
    Bag of options to control resource's behavior.
    name string
    The unique name of the resource.
    args SinkPolicyArgs
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    name String
    The unique name of the resource.
    args 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",
    });
    
    example, err := oam.NewSinkPolicy(ctx, "sinkPolicyResource", &oam.SinkPolicyArgs{
    	Policy:         pulumi.String("string"),
    	SinkIdentifier: pulumi.String("string"),
    })
    
    var sinkPolicyResource = new SinkPolicy("sinkPolicyResource", SinkPolicyArgs.builder()
        .policy("string")
        .sinkIdentifier("string")
        .build());
    
    sink_policy_resource = aws.oam.SinkPolicy("sinkPolicyResource",
        policy="string",
        sink_identifier="string")
    
    const sinkPolicyResource = new aws.oam.SinkPolicy("sinkPolicyResource", {
        policy: "string",
        sinkIdentifier: "string",
    });
    
    type: aws:oam:SinkPolicy
    properties:
        policy: string
        sinkIdentifier: string
    

    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

    The SinkPolicy resource accepts the following input properties:

    Policy string
    JSON policy to use. If you are updating an existing policy, the entire existing policy is replaced by what you specify here.
    SinkIdentifier string
    ARN of the sink to attach this policy to.
    Policy string
    JSON policy to use. If you are updating an existing policy, the entire existing policy is replaced by what you specify here.
    SinkIdentifier string
    ARN of the sink to attach this policy to.
    policy String
    JSON policy to use. If you are updating an existing policy, the entire existing policy is replaced by what you specify here.
    sinkIdentifier String
    ARN of the sink to attach this policy to.
    policy string
    JSON policy to use. If you are updating an existing policy, the entire existing policy is replaced by what you specify here.
    sinkIdentifier string
    ARN of the sink to attach this policy to.
    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_identifier str
    ARN of the sink to attach this policy to.
    policy String
    JSON policy to use. If you are updating an existing policy, the entire existing policy is replaced by what you specify here.
    sinkIdentifier 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)
    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:
    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 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 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 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 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 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 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
    

    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

    Try AWS Native preview for resources not in the classic version.

    AWS Classic v6.42.0 published on Wednesday, Jun 26, 2024 by Pulumi