ContainerPolicy class
Provides a MediaStore Container Policy.
> WARNING: This resource is deprecated and will be removed in a future version. AWS has announced the discontinuation of AWS Elemental MediaStore, effective November 13, 2025. Users should begin transitioning to alternative solutions as soon as possible. For simple live streaming workflows, AWS recommends migrating to Amazon S3. For advanced use cases that require features such as packaging, DRM, or cross-region redundancy, consider using AWS Elemental MediaPackage.
> NOTE: We suggest using jsonencode() or aws.iam.getPolicyDocument when assigning a value to policy. They seamlessly translate Terraform language into JSON, enabling you to maintain consistency within your configuration without the need for context switches. Also, you can sidestep potential complications arising from formatting discrepancies, whitespace inconsistencies, and other nuances inherent to JSON.
Example Usage
import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";
const current = aws.getRegion({});
const currentGetCallerIdentity = aws.getCallerIdentity({});
const exampleContainer = new aws.mediastore.Container("example", {name: "example"});
const example = aws.iam.getPolicyDocumentOutput({
statements: [{
conditions: [{
test: "Bool",
variable: "aws:SecureTransport",
values: ["true"],
}],
principals: [{
type: "AWS",
identifiers: [currentGetCallerIdentity.then(currentGetCallerIdentity => `arn:aws:iam::${currentGetCallerIdentity.accountId}:root`)],
}],
sid: "MediaStoreFullAccess",
effect: "Allow",
actions: ["mediastore:*"],
resources: [pulumi.all([current, currentGetCallerIdentity, exampleContainer.name]).apply(([current, currentGetCallerIdentity, name]) => `arn:aws:mediastore:${current.region}:${currentGetCallerIdentity.accountId}:container/${name}/*`)],
}],
});
const exampleContainerPolicy = new aws.mediastore.ContainerPolicy("example", {
containerName: exampleContainer.name,
policy: example.json,
});
import pulumi
import pulumi_aws as aws
current = aws.get_region()
current_get_caller_identity = aws.get_caller_identity()
example_container = aws.mediastore.Container("example", name="example")
example = aws.iam.get_policy_document_output(statements=[{
"conditions": [{
"test": "Bool",
"variable": "aws:SecureTransport",
"values": ["true"],
}],
"principals": [{
"type": "AWS",
"identifiers": [f"arn:aws:iam::{current_get_caller_identity.account_id}:root"],
}],
"sid": "MediaStoreFullAccess",
"effect": "Allow",
"actions": ["mediastore:*"],
"resources": [example_container.name.apply(lambda name: f"arn:aws:mediastore:{current.region}:{current_get_caller_identity.account_id}:container/{name}/*")],
}])
example_container_policy = aws.mediastore.ContainerPolicy("example",
container_name=example_container.name,
policy=example.json)
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Aws = Pulumi.Aws;
return await Deployment.RunAsync(() =>
{
var current = Aws.GetRegion.Invoke();
var currentGetCallerIdentity = Aws.GetCallerIdentity.Invoke();
var exampleContainer = new Aws.MediaStore.Container("example", new()
{
Name = "example",
});
var example = Aws.Iam.GetPolicyDocument.Invoke(new()
{
Statements = new[]
{
new Aws.Iam.Inputs.GetPolicyDocumentStatementInputArgs
{
Conditions = new[]
{
new Aws.Iam.Inputs.GetPolicyDocumentStatementConditionInputArgs
{
Test = "Bool",
Variable = "aws:SecureTransport",
Values = new[]
{
"true",
},
},
},
Principals = new[]
{
new Aws.Iam.Inputs.GetPolicyDocumentStatementPrincipalInputArgs
{
Type = "AWS",
Identifiers = new[]
{
$"arn:aws:iam::{currentGetCallerIdentity.Apply(getCallerIdentityResult => getCallerIdentityResult.AccountId)}:root",
},
},
},
Sid = "MediaStoreFullAccess",
Effect = "Allow",
Actions = new[]
{
"mediastore:*",
},
Resources = new[]
{
$"arn:aws:mediastore:{current.Apply(getRegionResult => getRegionResult.Region)}:{currentGetCallerIdentity.Apply(getCallerIdentityResult => getCallerIdentityResult.AccountId)}:container/{exampleContainer.Name}/*",
},
},
},
});
var exampleContainerPolicy = new Aws.MediaStore.ContainerPolicy("example", new()
{
ContainerName = exampleContainer.Name,
Policy = example.Apply(getPolicyDocumentResult => getPolicyDocumentResult.Json),
});
});
package main
import (
"fmt"
"github.com/pulumi/pulumi-aws/sdk/v7/go/aws"
"github.com/pulumi/pulumi-aws/sdk/v7/go/aws/iam"
"github.com/pulumi/pulumi-aws/sdk/v7/go/aws/mediastore"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
current, err := aws.GetRegion(ctx, &aws.GetRegionArgs{}, nil)
if err != nil {
return err
}
currentGetCallerIdentity, err := aws.GetCallerIdentity(ctx, &aws.GetCallerIdentityArgs{}, nil)
if err != nil {
return err
}
exampleContainer, err := mediastore.NewContainer(ctx, "example", &mediastore.ContainerArgs{
Name: pulumi.String("example"),
})
if err != nil {
return err
}
example := iam.GetPolicyDocumentOutput(ctx, iam.GetPolicyDocumentOutputArgs{
Statements: iam.GetPolicyDocumentStatementArray{
&iam.GetPolicyDocumentStatementArgs{
Conditions: iam.GetPolicyDocumentStatementConditionArray{
&iam.GetPolicyDocumentStatementConditionArgs{
Test: pulumi.String("Bool"),
Variable: pulumi.String("aws:SecureTransport"),
Values: pulumi.StringArray{
pulumi.String("true"),
},
},
},
Principals: iam.GetPolicyDocumentStatementPrincipalArray{
&iam.GetPolicyDocumentStatementPrincipalArgs{
Type: pulumi.String("AWS"),
Identifiers: pulumi.StringArray{
pulumi.Sprintf("arn:aws:iam::%v:root", currentGetCallerIdentity.AccountId),
},
},
},
Sid: pulumi.String("MediaStoreFullAccess"),
Effect: pulumi.String("Allow"),
Actions: pulumi.StringArray{
pulumi.String("mediastore:*"),
},
Resources: pulumi.StringArray{
exampleContainer.Name.ApplyT(func(name string) (string, error) {
return fmt.Sprintf("arn:aws:mediastore:%v:%v:container/%v/*", current.Region, currentGetCallerIdentity.AccountId, name), nil
}).(pulumi.StringOutput),
},
},
},
}, nil)
_, err = mediastore.NewContainerPolicy(ctx, "example", &mediastore.ContainerPolicyArgs{
ContainerName: exampleContainer.Name,
Policy: example.Json(),
})
if err != nil {
return err
}
return nil
})
}
pulumi {
required_providers {
aws = {
source = "pulumi/aws"
}
}
}
data "aws_getregion" "current" {
}
data "aws_getcalleridentity" "currentGetCallerIdentity" {
}
data "aws_iam_getpolicydocument" "example" {
statements {
conditions {
test = "Bool"
variable = "aws:SecureTransport"
values = ["true"]
}
principals {
type = "AWS"
identifiers = ["arn:aws:iam::${data.aws_getcalleridentity.currentGetCallerIdentity.account_id}:root"]
}
sid = "MediaStoreFullAccess"
effect = "Allow"
actions = ["mediastore:*"]
resources = ["arn:aws:mediastore:${data.aws_getregion.current.region}:${data.aws_getcalleridentity.currentGetCallerIdentity.account_id}:container/${aws_mediastore_container.example.name}/*"]
}
}
resource "aws_mediastore_container" "example" {
name = "example"
}
resource "aws_mediastore_containerpolicy" "example" {
container_name = aws_mediastore_container.example.name
policy = data.aws_iam_getpolicydocument.example.json
}
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.GetRegionArgs;
import com.pulumi.aws.inputs.GetCallerIdentityArgs;
import com.pulumi.aws.mediastore.Container;
import com.pulumi.aws.mediastore.ContainerArgs;
import com.pulumi.aws.iam.IamFunctions;
import com.pulumi.aws.iam.inputs.GetPolicyDocumentArgs;
import com.pulumi.aws.iam.inputs.GetPolicyDocumentStatementArgs;
import com.pulumi.aws.iam.inputs.GetPolicyDocumentStatementConditionArgs;
import com.pulumi.aws.iam.inputs.GetPolicyDocumentStatementPrincipalArgs;
import com.pulumi.aws.mediastore.ContainerPolicy;
import com.pulumi.aws.mediastore.ContainerPolicyArgs;
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.getRegion(GetRegionArgs.builder()
.build());
final var currentGetCallerIdentity = AwsFunctions.getCallerIdentity(GetCallerIdentityArgs.builder()
.build());
var exampleContainer = new Container("exampleContainer", ContainerArgs.builder()
.name("example")
.build());
final var example = IamFunctions.getPolicyDocument(GetPolicyDocumentArgs.builder()
.statements(GetPolicyDocumentStatementArgs.builder()
.conditions(GetPolicyDocumentStatementConditionArgs.builder()
.test("Bool")
.variable("aws:SecureTransport")
.values("true")
.build())
.principals(GetPolicyDocumentStatementPrincipalArgs.builder()
.type("AWS")
.identifiers(String.format("arn:aws:iam::%s:root", currentGetCallerIdentity.accountId()))
.build())
.sid("MediaStoreFullAccess")
.effect("Allow")
.actions("mediastore:*")
.resources(exampleContainer.name().applyValue(_name -> String.format("arn:aws:mediastore:%s:%s:container/%s/*", current.region(),currentGetCallerIdentity.accountId(),_name)))
.build())
.build());
var exampleContainerPolicy = new ContainerPolicy("exampleContainerPolicy", ContainerPolicyArgs.builder()
.containerName(exampleContainer.name())
.policy(example.applyValue(_example -> _example.json()))
.build());
}
}
resources:
exampleContainer:
type: aws:mediastore:Container
name: example
properties:
name: example
exampleContainerPolicy:
type: aws:mediastore:ContainerPolicy
name: example
properties:
containerName: ${exampleContainer.name}
policy: ${example.json}
variables:
current:
fn::invoke:
function: aws:getRegion
arguments: {}
currentGetCallerIdentity:
fn::invoke:
function: aws:getCallerIdentity
arguments: {}
example:
fn::invoke:
function: aws:iam:getPolicyDocument
arguments:
statements:
- conditions:
- test: Bool
variable: aws:SecureTransport
values:
- 'true'
principals:
- type: AWS
identifiers:
- arn:aws:iam::${currentGetCallerIdentity.accountId}:root
sid: MediaStoreFullAccess
effect: Allow
actions:
- mediastore:*
resources:
- arn:aws:mediastore:${current.region}:${currentGetCallerIdentity.accountId}:container/${exampleContainer.name}/*
Import
Using pulumi import, import MediaStore Container Policy using the MediaStore Container Name. For example:
$ pulumi import aws:mediastore/containerPolicy:ContainerPolicy example example
Constructors
- ContainerPolicy(String name, {ContainerPolicyArgs? args, CustomResourceOptions? options})
-
Creates a new ContainerPolicy.
nameThe Pulumi resource name.argsArguments used to configure this ContainerPolicy. The set of arguments for ContainerPolicy.optionsResource options controlling this resource's behavior. - ContainerPolicy.reference(String urn)
- Creates a typed reference to an existing ContainerPolicy resource.
Properties
-
childResources
→ Set<
Resource> -
finalinherited
-
completionSources
↔ Map<
String, IOutputCompletionSource> -
latefinalinherited
-
containerName
↔ Output<
String> -
The name of the container.
latefinal
- 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> -
The contents of the policy.
latefinal
-
region
↔ Output<
String> -
Region where this resource will be managed. Defaults to the Region set in the provider configuration.
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, {ContainerPolicyState? state, CustomResourceOptions? options}) → ContainerPolicy -
Gets an existing ContainerPolicy resource's state with the given
nameandid.