github.com/pulumi/pulumi-aws/sdk/v6@v6.32.0/go/aws/mediastore/containerPolicy.go (about)

     1  // Code generated by the Pulumi Terraform Bridge (tfgen) Tool DO NOT EDIT.
     2  // *** WARNING: Do not edit by hand unless you're certain you know what you are doing! ***
     3  
     4  package mediastore
     5  
     6  import (
     7  	"context"
     8  	"reflect"
     9  
    10  	"errors"
    11  	"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/internal"
    12  	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    13  )
    14  
    15  // ## Example Usage
    16  //
    17  // <!--Start PulumiCodeChooser -->
    18  // ```go
    19  // package main
    20  //
    21  // import (
    22  //
    23  //	"fmt"
    24  //
    25  //	"github.com/pulumi/pulumi-aws/sdk/v6/go/aws"
    26  //	"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/iam"
    27  //	"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/mediastore"
    28  //	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    29  //
    30  // )
    31  //
    32  //	func main() {
    33  //		pulumi.Run(func(ctx *pulumi.Context) error {
    34  //			current, err := aws.GetRegion(ctx, nil, nil)
    35  //			if err != nil {
    36  //				return err
    37  //			}
    38  //			currentGetCallerIdentity, err := aws.GetCallerIdentity(ctx, nil, nil)
    39  //			if err != nil {
    40  //				return err
    41  //			}
    42  //			exampleContainer, err := mediastore.NewContainer(ctx, "example", &mediastore.ContainerArgs{
    43  //				Name: pulumi.String("example"),
    44  //			})
    45  //			if err != nil {
    46  //				return err
    47  //			}
    48  //			example := iam.GetPolicyDocumentOutput(ctx, iam.GetPolicyDocumentOutputArgs{
    49  //				Statements: iam.GetPolicyDocumentStatementArray{
    50  //					&iam.GetPolicyDocumentStatementArgs{
    51  //						Sid:    pulumi.String("MediaStoreFullAccess"),
    52  //						Effect: pulumi.String("Allow"),
    53  //						Principals: iam.GetPolicyDocumentStatementPrincipalArray{
    54  //							&iam.GetPolicyDocumentStatementPrincipalArgs{
    55  //								Type: pulumi.String("AWS"),
    56  //								Identifiers: pulumi.StringArray{
    57  //									pulumi.String(fmt.Sprintf("arn:aws:iam::%v:root", currentGetCallerIdentity.AccountId)),
    58  //								},
    59  //							},
    60  //						},
    61  //						Actions: pulumi.StringArray{
    62  //							pulumi.String("mediastore:*"),
    63  //						},
    64  //						Resources: pulumi.StringArray{
    65  //							exampleContainer.Name.ApplyT(func(name string) (string, error) {
    66  //								return fmt.Sprintf("arn:aws:mediastore:%v:%v:container/%v/*", current.Name, currentGetCallerIdentity.AccountId, name), nil
    67  //							}).(pulumi.StringOutput),
    68  //						},
    69  //						Conditions: iam.GetPolicyDocumentStatementConditionArray{
    70  //							&iam.GetPolicyDocumentStatementConditionArgs{
    71  //								Test:     pulumi.String("Bool"),
    72  //								Variable: pulumi.String("aws:SecureTransport"),
    73  //								Values: pulumi.StringArray{
    74  //									pulumi.String("true"),
    75  //								},
    76  //							},
    77  //						},
    78  //					},
    79  //				},
    80  //			}, nil)
    81  //			_, err = mediastore.NewContainerPolicy(ctx, "example", &mediastore.ContainerPolicyArgs{
    82  //				ContainerName: exampleContainer.Name,
    83  //				Policy: example.ApplyT(func(example iam.GetPolicyDocumentResult) (*string, error) {
    84  //					return &example.Json, nil
    85  //				}).(pulumi.StringPtrOutput),
    86  //			})
    87  //			if err != nil {
    88  //				return err
    89  //			}
    90  //			return nil
    91  //		})
    92  //	}
    93  //
    94  // ```
    95  // <!--End PulumiCodeChooser -->
    96  //
    97  // ## Import
    98  //
    99  // Using `pulumi import`, import MediaStore Container Policy using the MediaStore Container Name. For example:
   100  //
   101  // ```sh
   102  // $ pulumi import aws:mediastore/containerPolicy:ContainerPolicy example example
   103  // ```
   104  type ContainerPolicy struct {
   105  	pulumi.CustomResourceState
   106  
   107  	// The name of the container.
   108  	ContainerName pulumi.StringOutput `pulumi:"containerName"`
   109  	// The contents of the policy.
   110  	Policy pulumi.StringOutput `pulumi:"policy"`
   111  }
   112  
   113  // NewContainerPolicy registers a new resource with the given unique name, arguments, and options.
   114  func NewContainerPolicy(ctx *pulumi.Context,
   115  	name string, args *ContainerPolicyArgs, opts ...pulumi.ResourceOption) (*ContainerPolicy, error) {
   116  	if args == nil {
   117  		return nil, errors.New("missing one or more required arguments")
   118  	}
   119  
   120  	if args.ContainerName == nil {
   121  		return nil, errors.New("invalid value for required argument 'ContainerName'")
   122  	}
   123  	if args.Policy == nil {
   124  		return nil, errors.New("invalid value for required argument 'Policy'")
   125  	}
   126  	opts = internal.PkgResourceDefaultOpts(opts)
   127  	var resource ContainerPolicy
   128  	err := ctx.RegisterResource("aws:mediastore/containerPolicy:ContainerPolicy", name, args, &resource, opts...)
   129  	if err != nil {
   130  		return nil, err
   131  	}
   132  	return &resource, nil
   133  }
   134  
   135  // GetContainerPolicy gets an existing ContainerPolicy resource's state with the given name, ID, and optional
   136  // state properties that are used to uniquely qualify the lookup (nil if not required).
   137  func GetContainerPolicy(ctx *pulumi.Context,
   138  	name string, id pulumi.IDInput, state *ContainerPolicyState, opts ...pulumi.ResourceOption) (*ContainerPolicy, error) {
   139  	var resource ContainerPolicy
   140  	err := ctx.ReadResource("aws:mediastore/containerPolicy:ContainerPolicy", name, id, state, &resource, opts...)
   141  	if err != nil {
   142  		return nil, err
   143  	}
   144  	return &resource, nil
   145  }
   146  
   147  // Input properties used for looking up and filtering ContainerPolicy resources.
   148  type containerPolicyState struct {
   149  	// The name of the container.
   150  	ContainerName *string `pulumi:"containerName"`
   151  	// The contents of the policy.
   152  	Policy *string `pulumi:"policy"`
   153  }
   154  
   155  type ContainerPolicyState struct {
   156  	// The name of the container.
   157  	ContainerName pulumi.StringPtrInput
   158  	// The contents of the policy.
   159  	Policy pulumi.StringPtrInput
   160  }
   161  
   162  func (ContainerPolicyState) ElementType() reflect.Type {
   163  	return reflect.TypeOf((*containerPolicyState)(nil)).Elem()
   164  }
   165  
   166  type containerPolicyArgs struct {
   167  	// The name of the container.
   168  	ContainerName string `pulumi:"containerName"`
   169  	// The contents of the policy.
   170  	Policy string `pulumi:"policy"`
   171  }
   172  
   173  // The set of arguments for constructing a ContainerPolicy resource.
   174  type ContainerPolicyArgs struct {
   175  	// The name of the container.
   176  	ContainerName pulumi.StringInput
   177  	// The contents of the policy.
   178  	Policy pulumi.StringInput
   179  }
   180  
   181  func (ContainerPolicyArgs) ElementType() reflect.Type {
   182  	return reflect.TypeOf((*containerPolicyArgs)(nil)).Elem()
   183  }
   184  
   185  type ContainerPolicyInput interface {
   186  	pulumi.Input
   187  
   188  	ToContainerPolicyOutput() ContainerPolicyOutput
   189  	ToContainerPolicyOutputWithContext(ctx context.Context) ContainerPolicyOutput
   190  }
   191  
   192  func (*ContainerPolicy) ElementType() reflect.Type {
   193  	return reflect.TypeOf((**ContainerPolicy)(nil)).Elem()
   194  }
   195  
   196  func (i *ContainerPolicy) ToContainerPolicyOutput() ContainerPolicyOutput {
   197  	return i.ToContainerPolicyOutputWithContext(context.Background())
   198  }
   199  
   200  func (i *ContainerPolicy) ToContainerPolicyOutputWithContext(ctx context.Context) ContainerPolicyOutput {
   201  	return pulumi.ToOutputWithContext(ctx, i).(ContainerPolicyOutput)
   202  }
   203  
   204  // ContainerPolicyArrayInput is an input type that accepts ContainerPolicyArray and ContainerPolicyArrayOutput values.
   205  // You can construct a concrete instance of `ContainerPolicyArrayInput` via:
   206  //
   207  //	ContainerPolicyArray{ ContainerPolicyArgs{...} }
   208  type ContainerPolicyArrayInput interface {
   209  	pulumi.Input
   210  
   211  	ToContainerPolicyArrayOutput() ContainerPolicyArrayOutput
   212  	ToContainerPolicyArrayOutputWithContext(context.Context) ContainerPolicyArrayOutput
   213  }
   214  
   215  type ContainerPolicyArray []ContainerPolicyInput
   216  
   217  func (ContainerPolicyArray) ElementType() reflect.Type {
   218  	return reflect.TypeOf((*[]*ContainerPolicy)(nil)).Elem()
   219  }
   220  
   221  func (i ContainerPolicyArray) ToContainerPolicyArrayOutput() ContainerPolicyArrayOutput {
   222  	return i.ToContainerPolicyArrayOutputWithContext(context.Background())
   223  }
   224  
   225  func (i ContainerPolicyArray) ToContainerPolicyArrayOutputWithContext(ctx context.Context) ContainerPolicyArrayOutput {
   226  	return pulumi.ToOutputWithContext(ctx, i).(ContainerPolicyArrayOutput)
   227  }
   228  
   229  // ContainerPolicyMapInput is an input type that accepts ContainerPolicyMap and ContainerPolicyMapOutput values.
   230  // You can construct a concrete instance of `ContainerPolicyMapInput` via:
   231  //
   232  //	ContainerPolicyMap{ "key": ContainerPolicyArgs{...} }
   233  type ContainerPolicyMapInput interface {
   234  	pulumi.Input
   235  
   236  	ToContainerPolicyMapOutput() ContainerPolicyMapOutput
   237  	ToContainerPolicyMapOutputWithContext(context.Context) ContainerPolicyMapOutput
   238  }
   239  
   240  type ContainerPolicyMap map[string]ContainerPolicyInput
   241  
   242  func (ContainerPolicyMap) ElementType() reflect.Type {
   243  	return reflect.TypeOf((*map[string]*ContainerPolicy)(nil)).Elem()
   244  }
   245  
   246  func (i ContainerPolicyMap) ToContainerPolicyMapOutput() ContainerPolicyMapOutput {
   247  	return i.ToContainerPolicyMapOutputWithContext(context.Background())
   248  }
   249  
   250  func (i ContainerPolicyMap) ToContainerPolicyMapOutputWithContext(ctx context.Context) ContainerPolicyMapOutput {
   251  	return pulumi.ToOutputWithContext(ctx, i).(ContainerPolicyMapOutput)
   252  }
   253  
   254  type ContainerPolicyOutput struct{ *pulumi.OutputState }
   255  
   256  func (ContainerPolicyOutput) ElementType() reflect.Type {
   257  	return reflect.TypeOf((**ContainerPolicy)(nil)).Elem()
   258  }
   259  
   260  func (o ContainerPolicyOutput) ToContainerPolicyOutput() ContainerPolicyOutput {
   261  	return o
   262  }
   263  
   264  func (o ContainerPolicyOutput) ToContainerPolicyOutputWithContext(ctx context.Context) ContainerPolicyOutput {
   265  	return o
   266  }
   267  
   268  // The name of the container.
   269  func (o ContainerPolicyOutput) ContainerName() pulumi.StringOutput {
   270  	return o.ApplyT(func(v *ContainerPolicy) pulumi.StringOutput { return v.ContainerName }).(pulumi.StringOutput)
   271  }
   272  
   273  // The contents of the policy.
   274  func (o ContainerPolicyOutput) Policy() pulumi.StringOutput {
   275  	return o.ApplyT(func(v *ContainerPolicy) pulumi.StringOutput { return v.Policy }).(pulumi.StringOutput)
   276  }
   277  
   278  type ContainerPolicyArrayOutput struct{ *pulumi.OutputState }
   279  
   280  func (ContainerPolicyArrayOutput) ElementType() reflect.Type {
   281  	return reflect.TypeOf((*[]*ContainerPolicy)(nil)).Elem()
   282  }
   283  
   284  func (o ContainerPolicyArrayOutput) ToContainerPolicyArrayOutput() ContainerPolicyArrayOutput {
   285  	return o
   286  }
   287  
   288  func (o ContainerPolicyArrayOutput) ToContainerPolicyArrayOutputWithContext(ctx context.Context) ContainerPolicyArrayOutput {
   289  	return o
   290  }
   291  
   292  func (o ContainerPolicyArrayOutput) Index(i pulumi.IntInput) ContainerPolicyOutput {
   293  	return pulumi.All(o, i).ApplyT(func(vs []interface{}) *ContainerPolicy {
   294  		return vs[0].([]*ContainerPolicy)[vs[1].(int)]
   295  	}).(ContainerPolicyOutput)
   296  }
   297  
   298  type ContainerPolicyMapOutput struct{ *pulumi.OutputState }
   299  
   300  func (ContainerPolicyMapOutput) ElementType() reflect.Type {
   301  	return reflect.TypeOf((*map[string]*ContainerPolicy)(nil)).Elem()
   302  }
   303  
   304  func (o ContainerPolicyMapOutput) ToContainerPolicyMapOutput() ContainerPolicyMapOutput {
   305  	return o
   306  }
   307  
   308  func (o ContainerPolicyMapOutput) ToContainerPolicyMapOutputWithContext(ctx context.Context) ContainerPolicyMapOutput {
   309  	return o
   310  }
   311  
   312  func (o ContainerPolicyMapOutput) MapIndex(k pulumi.StringInput) ContainerPolicyOutput {
   313  	return pulumi.All(o, k).ApplyT(func(vs []interface{}) *ContainerPolicy {
   314  		return vs[0].(map[string]*ContainerPolicy)[vs[1].(string)]
   315  	}).(ContainerPolicyOutput)
   316  }
   317  
   318  func init() {
   319  	pulumi.RegisterInputType(reflect.TypeOf((*ContainerPolicyInput)(nil)).Elem(), &ContainerPolicy{})
   320  	pulumi.RegisterInputType(reflect.TypeOf((*ContainerPolicyArrayInput)(nil)).Elem(), ContainerPolicyArray{})
   321  	pulumi.RegisterInputType(reflect.TypeOf((*ContainerPolicyMapInput)(nil)).Elem(), ContainerPolicyMap{})
   322  	pulumi.RegisterOutputType(ContainerPolicyOutput{})
   323  	pulumi.RegisterOutputType(ContainerPolicyArrayOutput{})
   324  	pulumi.RegisterOutputType(ContainerPolicyMapOutput{})
   325  }