ContainerPolicy

Provides a MediaStore Container Policy.

Example Usage

using Pulumi;
using Aws = Pulumi.Aws;

class MyStack : Stack
{
    public MyStack()
    {
        var currentRegion = Output.Create(Aws.GetRegion.InvokeAsync());
        var currentCallerIdentity = Output.Create(Aws.GetCallerIdentity.InvokeAsync());
        var exampleContainer = new Aws.MediaStore.Container("exampleContainer", new Aws.MediaStore.ContainerArgs
        {
        });
        var exampleContainerPolicy = new Aws.MediaStore.ContainerPolicy("exampleContainerPolicy", new Aws.MediaStore.ContainerPolicyArgs
        {
            ContainerName = exampleContainer.Name,
            Policy = Output.Tuple(currentCallerIdentity, currentRegion, currentCallerIdentity, exampleContainer.Name).Apply(values =>
            {
                var currentCallerIdentity = values.Item1;
                var currentRegion = values.Item2;
                var currentCallerIdentity1 = values.Item3;
                var name = values.Item4;
                return @$"{{
 ""Version"": ""2012-10-17"",
 ""Statement"": [{{
     ""Sid"": ""MediaStoreFullAccess"",
     ""Action"": [ ""mediastore:*"" ],
     ""Principal"": {{""AWS"" : ""arn:aws:iam::{currentCallerIdentity.AccountId}:root""}},
     ""Effect"": ""Allow"",
     ""Resource"": ""arn:aws:mediastore:{currentRegion.Name}:{currentCallerIdentity1.AccountId}:container/{name}/*"",
     ""Condition"": {{
         ""Bool"": {{ ""aws:SecureTransport"": ""true"" }}
     }}
 }}]
}}

";
            }),
        });
    }

}
package main

import (
    "fmt"

    "github.com/pulumi/pulumi-aws/sdk/v2/go/aws"
    "github.com/pulumi/pulumi-aws/sdk/v2/go/aws/mediastore"
    "github.com/pulumi/pulumi/sdk/v2/go/pulumi"
)

func main() {
    pulumi.Run(func(ctx *pulumi.Context) error {
        currentRegion, err := aws.GetRegion(ctx, nil, nil)
        if err != nil {
            return err
        }
        currentCallerIdentity, err := aws.GetCallerIdentity(ctx, nil, nil)
        if err != nil {
            return err
        }
        exampleContainer, err := mediastore.NewContainer(ctx, "exampleContainer", nil)
        if err != nil {
            return err
        }
        _, err = mediastore.NewContainerPolicy(ctx, "exampleContainerPolicy", &mediastore.ContainerPolicyArgs{
            ContainerName: exampleContainer.Name,
            Policy: exampleContainer.Name.ApplyT(func(name string) (string, error) {
                return fmt.Sprintf("%v%v%v%v%v%v%v%v%v%v%v%v%v%v%v%v%v%v%v%v%v%v", "{\n", "    \"Version\": \"2012-10-17\",\n", "    \"Statement\": [{\n", "       \"Sid\": \"MediaStoreFullAccess\",\n", "      \"Action\": [ \"mediastore:*\" ],\n", "       \"Principal\": {\"AWS\" : \"arn:aws:iam::", currentCallerIdentity.AccountId, ":root\"},\n", "     \"Effect\": \"Allow\",\n", "      \"Resource\": \"arn:aws:mediastore:", currentRegion.Name, ":", currentCallerIdentity.AccountId, ":container/", name, "/*\",\n", "        \"Condition\": {\n", "            \"Bool\": { \"aws:SecureTransport\": \"true\" }\n", "     }\n", "   }]\n", "}\n", "\n"), nil
            }).(pulumi.StringOutput),
        })
        if err != nil {
            return err
        }
        return nil
    })
}
import pulumi
import pulumi_aws as aws

current_region = aws.get_region()
current_caller_identity = aws.get_caller_identity()
example_container = aws.mediastore.Container("exampleContainer")
example_container_policy = aws.mediastore.ContainerPolicy("exampleContainerPolicy",
    container_name=example_container.name,
    policy=example_container.name.apply(lambda name: f"""{{
    "Version": "2012-10-17",
    "Statement": [{{
        "Sid": "MediaStoreFullAccess",
        "Action": [ "mediastore:*" ],
        "Principal": {{"AWS" : "arn:aws:iam::{current_caller_identity.account_id}:root"}},
        "Effect": "Allow",
        "Resource": "arn:aws:mediastore:{current_region.name}:{current_caller_identity.account_id}:container/{name}/*",
        "Condition": {{
            "Bool": {{ "aws:SecureTransport": "true" }}
        }}
    }}]
}}

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

const currentRegion = pulumi.output(aws.getRegion({ async: true }));
const currentCallerIdentity = pulumi.output(aws.getCallerIdentity({ async: true }));
const exampleContainer = new aws.mediastore.Container("example", {});
const exampleContainerPolicy = new aws.mediastore.ContainerPolicy("example", {
    containerName: exampleContainer.name,
    policy: pulumi.interpolate`{
    "Version": "2012-10-17",
    "Statement": [{
        "Sid": "MediaStoreFullAccess",
        "Action": [ "mediastore:*" ],
        "Principal": {"AWS" : "arn:aws:iam::${currentCallerIdentity.accountId}:root"},
        "Effect": "Allow",
        "Resource": "arn:aws:mediastore:${currentRegion.name!}:${currentCallerIdentity.accountId}:container/${exampleContainer.name}/*",
        "Condition": {
            "Bool": { "aws:SecureTransport": "true" }
        }
    }]
}
`,
});

Create a ContainerPolicy Resource

def ContainerPolicy(resource_name, opts=None, container_name=None, policy=None, __props__=None);
name string
The unique name of the resource.
args ContainerPolicyArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
resource_name str
The unique name of the resource.
opts ResourceOptions
A bag of options that control this resource's behavior.
ctx Context
Context object for the current deployment.
name string
The unique name of the resource.
args ContainerPolicyArgs
The arguments to resource properties.
opts ResourceOption
Bag of options to control resource's behavior.
name string
The unique name of the resource.
args ContainerPolicyArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.

ContainerPolicy Resource Properties

To learn more about resource properties and how to use them, see Inputs and Outputs in the Programming Model docs.

Inputs

The ContainerPolicy resource accepts the following input properties:

ContainerName string

The name of the container.

Policy string

The contents of the policy.

ContainerName string

The name of the container.

Policy string

The contents of the policy.

containerName string

The name of the container.

policy string

The contents of the policy.

container_name str

The name of the container.

policy str

The contents of the policy.

Outputs

All input properties are implicitly available as output properties. Additionally, the ContainerPolicy 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 str
The provider-assigned unique ID for this managed resource.

Look up an Existing ContainerPolicy Resource

Get an existing ContainerPolicy 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?: ContainerPolicyState, opts?: CustomResourceOptions): ContainerPolicy
static get(resource_name, id, opts=None, container_name=None, policy=None, __props__=None);
func GetContainerPolicy(ctx *Context, name string, id IDInput, state *ContainerPolicyState, opts ...ResourceOption) (*ContainerPolicy, error)
public static ContainerPolicy Get(string name, Input<string> id, ContainerPolicyState? state, CustomResourceOptions? opts = null)
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.

The following state arguments are supported:

ContainerName string

The name of the container.

Policy string

The contents of the policy.

ContainerName string

The name of the container.

Policy string

The contents of the policy.

containerName string

The name of the container.

policy string

The contents of the policy.

container_name str

The name of the container.

policy str

The contents of the policy.

Package Details

Repository
https://github.com/pulumi/pulumi-aws
License
Apache-2.0
Notes
This Pulumi package is based on the aws Terraform Provider.