AWS Classic

Pulumi Official
Package maintained by Pulumi
v5.4.0 published on Wednesday, May 4, 2022 by Pulumi

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/v5/go/aws"
	"github.com/pulumi/pulumi-aws/sdk/v5/go/aws/mediastore"
	"github.com/pulumi/pulumi/sdk/v3/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", "{\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"), nil
			}).(pulumi.StringOutput),
		})
		if err != nil {
			return err
		}
		return nil
	})
}
package generated_program;

import java.util.*;
import java.io.*;
import java.nio.*;
import com.pulumi.*;

public class App {
    public static void main(String[] args) {
        Pulumi.run(App::stack);
    }

    public static void stack(Context ctx) {
        final var currentRegion = Output.of(AwsFunctions.getRegion());

        final var currentCallerIdentity = Output.of(AwsFunctions.getCallerIdentity());

        var exampleContainer = new Container("exampleContainer");

        var exampleContainerPolicy = new ContainerPolicy("exampleContainerPolicy", ContainerPolicyArgs.builder()        
            .containerName(exampleContainer.getName())
            .policy(exampleContainer.getName().apply(name -> """
{
	"Version": "2012-10-17",
	"Statement": [{
		"Sid": "MediaStoreFullAccess",
		"Action": [ "mediastore:*" ],
		"Principal": {"AWS" : "arn:aws:iam::%s:root"},
		"Effect": "Allow",
		"Resource": "arn:aws:mediastore:%s:%s:container/%s/*",
		"Condition": {
			"Bool": { "aws:SecureTransport": "true" }
		}
	}]
}
", currentCallerIdentity.apply(getCallerIdentityResult -> getCallerIdentityResult.getAccountId()),currentRegion.apply(getRegionResult -> getRegionResult.getName()),currentCallerIdentity.apply(getCallerIdentityResult -> getCallerIdentityResult.getAccountId()),name)))
            .build());

        }
}
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 = aws.getRegion({});
const currentCallerIdentity = aws.getCallerIdentity({});
const exampleContainer = new aws.mediastore.Container("exampleContainer", {});
const exampleContainerPolicy = new aws.mediastore.ContainerPolicy("exampleContainerPolicy", {
    containerName: exampleContainer.name,
    policy: pulumi.all([currentCallerIdentity, currentRegion, currentCallerIdentity, exampleContainer.name]).apply(([currentCallerIdentity, currentRegion, currentCallerIdentity1, name]) => `{
	"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" }
		}
	}]
}
`),
});
resources:
  exampleContainer:
    type: aws:mediastore:Container
  exampleContainerPolicy:
    type: aws:mediastore:ContainerPolicy
    properties:
      containerName: ${exampleContainer.name}
      policy: |
        {
        	"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" }
        		}
        	}]
        }        
variables:
  currentRegion:
    Fn::Invoke:
      Function: aws:getRegion
      Arguments: {}
  currentCallerIdentity:
    Fn::Invoke:
      Function: aws:getCallerIdentity
      Arguments: {}

Create a ContainerPolicy Resource

new ContainerPolicy(name: string, args: ContainerPolicyArgs, opts?: CustomResourceOptions);
@overload
def ContainerPolicy(resource_name: str,
                    opts: Optional[ResourceOptions] = None,
                    container_name: Optional[str] = None,
                    policy: Optional[str] = None)
@overload
def ContainerPolicy(resource_name: str,
                    args: ContainerPolicyArgs,
                    opts: Optional[ResourceOptions] = None)
func NewContainerPolicy(ctx *Context, name string, args ContainerPolicyArgs, opts ...ResourceOption) (*ContainerPolicy, error)
public ContainerPolicy(string name, ContainerPolicyArgs args, CustomResourceOptions? opts = null)
public ContainerPolicy(String name, ContainerPolicyArgs args)
public ContainerPolicy(String name, ContainerPolicyArgs args, CustomResourceOptions options)
type: aws:mediastore:ContainerPolicy
properties: # The arguments to resource properties.
options: # 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.
resource_name str
The unique name of the resource.
args ContainerPolicyArgs
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 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.
name String
The unique name of the resource.
args ContainerPolicyArgs
The arguments to resource properties.
options 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 Architecture and Concepts 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.

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.

containerName String

The name of the container.

policy String

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 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 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
@staticmethod
def get(resource_name: str,
        id: str,
        opts: Optional[ResourceOptions] = None,
        container_name: Optional[str] = None,
        policy: Optional[str] = None) -> ContainerPolicy
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)
public static ContainerPolicy get(String name, Output<String> id, ContainerPolicyState 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:
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.

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.

containerName String

The name of the container.

policy String

The contents of the policy.

Import

MediaStore Container Policy can be imported using the MediaStore Container Name, e.g.,

 $ pulumi import aws:mediastore/containerPolicy:ContainerPolicy example example

Package Details

Repository
https://github.com/pulumi/pulumi-aws
License
Apache-2.0
Notes

This Pulumi package is based on the aws Terraform Provider.