aws.mediastore.ContainerPolicy
Explore with Pulumi AI
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: [{
sid: "MediaStoreFullAccess",
effect: "Allow",
principals: [{
type: "AWS",
identifiers: [currentGetCallerIdentity.then(currentGetCallerIdentity => `arn:aws:iam::${currentGetCallerIdentity.accountId}:root`)],
}],
actions: ["mediastore:*"],
resources: [pulumi.all([current, currentGetCallerIdentity, exampleContainer.name]).apply(([current, currentGetCallerIdentity, name]) => `arn:aws:mediastore:${current.name}:${currentGetCallerIdentity.accountId}:container/${name}/*`)],
conditions: [{
test: "Bool",
variable: "aws:SecureTransport",
values: ["true"],
}],
}],
});
const exampleContainerPolicy = new aws.mediastore.ContainerPolicy("example", {
containerName: exampleContainer.name,
policy: example.apply(example => 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=[{
"sid": "MediaStoreFullAccess",
"effect": "Allow",
"principals": [{
"type": "AWS",
"identifiers": [f"arn:aws:iam::{current_get_caller_identity.account_id}:root"],
}],
"actions": ["mediastore:*"],
"resources": [example_container.name.apply(lambda name: f"arn:aws:mediastore:{current.name}:{current_get_caller_identity.account_id}:container/{name}/*")],
"conditions": [{
"test": "Bool",
"variable": "aws:SecureTransport",
"values": ["true"],
}],
}])
example_container_policy = aws.mediastore.ContainerPolicy("example",
container_name=example_container.name,
policy=example.json)
package main
import (
"fmt"
"github.com/pulumi/pulumi-aws/sdk/v6/go/aws"
"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/iam"
"github.com/pulumi/pulumi-aws/sdk/v6/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, nil, nil)
if err != nil {
return err
}
currentGetCallerIdentity, err := aws.GetCallerIdentity(ctx, nil, 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{
Sid: pulumi.String("MediaStoreFullAccess"),
Effect: pulumi.String("Allow"),
Principals: iam.GetPolicyDocumentStatementPrincipalArray{
&iam.GetPolicyDocumentStatementPrincipalArgs{
Type: pulumi.String("AWS"),
Identifiers: pulumi.StringArray{
pulumi.Sprintf("arn:aws:iam::%v:root", currentGetCallerIdentity.AccountId),
},
},
},
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.Name, currentGetCallerIdentity.AccountId, name), nil
}).(pulumi.StringOutput),
},
Conditions: iam.GetPolicyDocumentStatementConditionArray{
&iam.GetPolicyDocumentStatementConditionArgs{
Test: pulumi.String("Bool"),
Variable: pulumi.String("aws:SecureTransport"),
Values: pulumi.StringArray{
pulumi.String("true"),
},
},
},
},
},
}, nil)
_, err = mediastore.NewContainerPolicy(ctx, "example", &mediastore.ContainerPolicyArgs{
ContainerName: exampleContainer.Name,
Policy: pulumi.String(example.ApplyT(func(example iam.GetPolicyDocumentResult) (*string, error) {
return &example.Json, nil
}).(pulumi.StringPtrOutput)),
})
if err != nil {
return err
}
return nil
})
}
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
{
Sid = "MediaStoreFullAccess",
Effect = "Allow",
Principals = new[]
{
new Aws.Iam.Inputs.GetPolicyDocumentStatementPrincipalInputArgs
{
Type = "AWS",
Identifiers = new[]
{
$"arn:aws:iam::{currentGetCallerIdentity.Apply(getCallerIdentityResult => getCallerIdentityResult.AccountId)}:root",
},
},
},
Actions = new[]
{
"mediastore:*",
},
Resources = new[]
{
$"arn:aws:mediastore:{current.Apply(getRegionResult => getRegionResult.Name)}:{currentGetCallerIdentity.Apply(getCallerIdentityResult => getCallerIdentityResult.AccountId)}:container/{exampleContainer.Name}/*",
},
Conditions = new[]
{
new Aws.Iam.Inputs.GetPolicyDocumentStatementConditionInputArgs
{
Test = "Bool",
Variable = "aws:SecureTransport",
Values = new[]
{
"true",
},
},
},
},
},
});
var exampleContainerPolicy = new Aws.MediaStore.ContainerPolicy("example", new()
{
ContainerName = exampleContainer.Name,
Policy = example.Apply(getPolicyDocumentResult => getPolicyDocumentResult.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.mediastore.ContainerPolicy;
import com.pulumi.aws.mediastore.ContainerPolicyArgs;
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) {
final var current = AwsFunctions.getRegion();
final var currentGetCallerIdentity = AwsFunctions.getCallerIdentity();
var exampleContainer = new Container("exampleContainer", ContainerArgs.builder()
.name("example")
.build());
final var example = IamFunctions.getPolicyDocument(GetPolicyDocumentArgs.builder()
.statements(GetPolicyDocumentStatementArgs.builder()
.sid("MediaStoreFullAccess")
.effect("Allow")
.principals(GetPolicyDocumentStatementPrincipalArgs.builder()
.type("AWS")
.identifiers(String.format("arn:aws:iam::%s:root", currentGetCallerIdentity.applyValue(getCallerIdentityResult -> getCallerIdentityResult.accountId())))
.build())
.actions("mediastore:*")
.resources(exampleContainer.name().applyValue(name -> String.format("arn:aws:mediastore:%s:%s:container/%s/*", current.applyValue(getRegionResult -> getRegionResult.name()),currentGetCallerIdentity.applyValue(getCallerIdentityResult -> getCallerIdentityResult.accountId()),name)))
.conditions(GetPolicyDocumentStatementConditionArgs.builder()
.test("Bool")
.variable("aws:SecureTransport")
.values("true")
.build())
.build())
.build());
var exampleContainerPolicy = new ContainerPolicy("exampleContainerPolicy", ContainerPolicyArgs.builder()
.containerName(exampleContainer.name())
.policy(example.applyValue(getPolicyDocumentResult -> getPolicyDocumentResult).applyValue(example -> example.applyValue(getPolicyDocumentResult -> getPolicyDocumentResult.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:
- sid: MediaStoreFullAccess
effect: Allow
principals:
- type: AWS
identifiers:
- arn:aws:iam::${currentGetCallerIdentity.accountId}:root
actions:
- mediastore:*
resources:
- arn:aws:mediastore:${current.name}:${currentGetCallerIdentity.accountId}:container/${exampleContainer.name}/*
conditions:
- test: Bool
variable: aws:SecureTransport
values:
- 'true'
Create ContainerPolicy Resource
Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.
Constructor syntax
new ContainerPolicy(name: string, args: ContainerPolicyArgs, opts?: CustomResourceOptions);
@overload
def ContainerPolicy(resource_name: str,
args: ContainerPolicyArgs,
opts: Optional[ResourceOptions] = None)
@overload
def ContainerPolicy(resource_name: str,
opts: Optional[ResourceOptions] = None,
container_name: Optional[str] = None,
policy: Optional[str] = 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.
Parameters
- 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.
Constructor example
The following reference example uses placeholder values for all input properties.
var containerPolicyResource = new Aws.MediaStore.ContainerPolicy("containerPolicyResource", new()
{
ContainerName = "string",
Policy = "string",
});
example, err := mediastore.NewContainerPolicy(ctx, "containerPolicyResource", &mediastore.ContainerPolicyArgs{
ContainerName: pulumi.String("string"),
Policy: pulumi.String("string"),
})
var containerPolicyResource = new ContainerPolicy("containerPolicyResource", ContainerPolicyArgs.builder()
.containerName("string")
.policy("string")
.build());
container_policy_resource = aws.mediastore.ContainerPolicy("containerPolicyResource",
container_name="string",
policy="string")
const containerPolicyResource = new aws.mediastore.ContainerPolicy("containerPolicyResource", {
containerName: "string",
policy: "string",
});
type: aws:mediastore:ContainerPolicy
properties:
containerName: string
policy: string
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:
- Container
Name string - The name of the container.
- Policy string
- The contents of the policy.
- Container
Name string - The name of the container.
- Policy string
- The contents of the policy.
- container
Name String - The name of the container.
- policy String
- The contents of the policy.
- container
Name 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.
- container
Name 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 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.
- Container
Name string - The name of the container.
- Policy string
- The contents of the policy.
- Container
Name string - The name of the container.
- Policy string
- The contents of the policy.
- container
Name String - The name of the container.
- policy String
- The contents of the policy.
- container
Name 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.
- container
Name String - The name of the container.
- policy String
- The contents of the policy.
Import
Using pulumi import
, import MediaStore Container Policy using the MediaStore Container Name. For example:
$ pulumi import aws:mediastore/containerPolicy:ContainerPolicy example example
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.