github.com/pulumi/pulumi-aws/sdk/v6@v6.32.0/go/aws/verifiedpermissions/policyTemplate.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 verifiedpermissions
     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  // Resource for managing an AWS Verified Permissions Policy Template.
    16  //
    17  // ## Example Usage
    18  //
    19  // ### Basic Usage
    20  //
    21  // <!--Start PulumiCodeChooser -->
    22  // ```go
    23  // package main
    24  //
    25  // import (
    26  //
    27  //	"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/verifiedpermissions"
    28  //	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    29  //
    30  // )
    31  //
    32  //	func main() {
    33  //		pulumi.Run(func(ctx *pulumi.Context) error {
    34  //			_, err := verifiedpermissions.NewPolicyTemplate(ctx, "example", &verifiedpermissions.PolicyTemplateArgs{
    35  //				PolicyStoreId: pulumi.Any(exampleAwsVerifiedpermissionsPolicyStore.Id),
    36  //				Statement:     pulumi.String("permit (principal in ?principal, action in PhotoFlash::Action::\"FullPhotoAccess\", resource == ?resource) unless { resource.IsPrivate };"),
    37  //			})
    38  //			if err != nil {
    39  //				return err
    40  //			}
    41  //			return nil
    42  //		})
    43  //	}
    44  //
    45  // ```
    46  // <!--End PulumiCodeChooser -->
    47  //
    48  // ## Import
    49  //
    50  // Using `pulumi import`, import Verified Permissions Policy Store using the `policy_store_id:policy_template_id`. For example:
    51  //
    52  // ```sh
    53  // $ pulumi import aws:verifiedpermissions/policyTemplate:PolicyTemplate example policyStoreId:policyTemplateId
    54  // ```
    55  type PolicyTemplate struct {
    56  	pulumi.CustomResourceState
    57  
    58  	// The date the Policy Store was created.
    59  	CreatedDate pulumi.StringOutput `pulumi:"createdDate"`
    60  	// Provides a description for the policy template.
    61  	Description pulumi.StringPtrOutput `pulumi:"description"`
    62  	// The ID of the Policy Store.
    63  	PolicyStoreId pulumi.StringOutput `pulumi:"policyStoreId"`
    64  	// The ID of the Policy Store.
    65  	PolicyTemplateId pulumi.StringOutput `pulumi:"policyTemplateId"`
    66  	// Defines the content of the statement, written in Cedar policy language.
    67  	//
    68  	// The following arguments are optional:
    69  	Statement pulumi.StringOutput `pulumi:"statement"`
    70  }
    71  
    72  // NewPolicyTemplate registers a new resource with the given unique name, arguments, and options.
    73  func NewPolicyTemplate(ctx *pulumi.Context,
    74  	name string, args *PolicyTemplateArgs, opts ...pulumi.ResourceOption) (*PolicyTemplate, error) {
    75  	if args == nil {
    76  		return nil, errors.New("missing one or more required arguments")
    77  	}
    78  
    79  	if args.PolicyStoreId == nil {
    80  		return nil, errors.New("invalid value for required argument 'PolicyStoreId'")
    81  	}
    82  	if args.Statement == nil {
    83  		return nil, errors.New("invalid value for required argument 'Statement'")
    84  	}
    85  	opts = internal.PkgResourceDefaultOpts(opts)
    86  	var resource PolicyTemplate
    87  	err := ctx.RegisterResource("aws:verifiedpermissions/policyTemplate:PolicyTemplate", name, args, &resource, opts...)
    88  	if err != nil {
    89  		return nil, err
    90  	}
    91  	return &resource, nil
    92  }
    93  
    94  // GetPolicyTemplate gets an existing PolicyTemplate resource's state with the given name, ID, and optional
    95  // state properties that are used to uniquely qualify the lookup (nil if not required).
    96  func GetPolicyTemplate(ctx *pulumi.Context,
    97  	name string, id pulumi.IDInput, state *PolicyTemplateState, opts ...pulumi.ResourceOption) (*PolicyTemplate, error) {
    98  	var resource PolicyTemplate
    99  	err := ctx.ReadResource("aws:verifiedpermissions/policyTemplate:PolicyTemplate", name, id, state, &resource, opts...)
   100  	if err != nil {
   101  		return nil, err
   102  	}
   103  	return &resource, nil
   104  }
   105  
   106  // Input properties used for looking up and filtering PolicyTemplate resources.
   107  type policyTemplateState struct {
   108  	// The date the Policy Store was created.
   109  	CreatedDate *string `pulumi:"createdDate"`
   110  	// Provides a description for the policy template.
   111  	Description *string `pulumi:"description"`
   112  	// The ID of the Policy Store.
   113  	PolicyStoreId *string `pulumi:"policyStoreId"`
   114  	// The ID of the Policy Store.
   115  	PolicyTemplateId *string `pulumi:"policyTemplateId"`
   116  	// Defines the content of the statement, written in Cedar policy language.
   117  	//
   118  	// The following arguments are optional:
   119  	Statement *string `pulumi:"statement"`
   120  }
   121  
   122  type PolicyTemplateState struct {
   123  	// The date the Policy Store was created.
   124  	CreatedDate pulumi.StringPtrInput
   125  	// Provides a description for the policy template.
   126  	Description pulumi.StringPtrInput
   127  	// The ID of the Policy Store.
   128  	PolicyStoreId pulumi.StringPtrInput
   129  	// The ID of the Policy Store.
   130  	PolicyTemplateId pulumi.StringPtrInput
   131  	// Defines the content of the statement, written in Cedar policy language.
   132  	//
   133  	// The following arguments are optional:
   134  	Statement pulumi.StringPtrInput
   135  }
   136  
   137  func (PolicyTemplateState) ElementType() reflect.Type {
   138  	return reflect.TypeOf((*policyTemplateState)(nil)).Elem()
   139  }
   140  
   141  type policyTemplateArgs struct {
   142  	// Provides a description for the policy template.
   143  	Description *string `pulumi:"description"`
   144  	// The ID of the Policy Store.
   145  	PolicyStoreId string `pulumi:"policyStoreId"`
   146  	// Defines the content of the statement, written in Cedar policy language.
   147  	//
   148  	// The following arguments are optional:
   149  	Statement string `pulumi:"statement"`
   150  }
   151  
   152  // The set of arguments for constructing a PolicyTemplate resource.
   153  type PolicyTemplateArgs struct {
   154  	// Provides a description for the policy template.
   155  	Description pulumi.StringPtrInput
   156  	// The ID of the Policy Store.
   157  	PolicyStoreId pulumi.StringInput
   158  	// Defines the content of the statement, written in Cedar policy language.
   159  	//
   160  	// The following arguments are optional:
   161  	Statement pulumi.StringInput
   162  }
   163  
   164  func (PolicyTemplateArgs) ElementType() reflect.Type {
   165  	return reflect.TypeOf((*policyTemplateArgs)(nil)).Elem()
   166  }
   167  
   168  type PolicyTemplateInput interface {
   169  	pulumi.Input
   170  
   171  	ToPolicyTemplateOutput() PolicyTemplateOutput
   172  	ToPolicyTemplateOutputWithContext(ctx context.Context) PolicyTemplateOutput
   173  }
   174  
   175  func (*PolicyTemplate) ElementType() reflect.Type {
   176  	return reflect.TypeOf((**PolicyTemplate)(nil)).Elem()
   177  }
   178  
   179  func (i *PolicyTemplate) ToPolicyTemplateOutput() PolicyTemplateOutput {
   180  	return i.ToPolicyTemplateOutputWithContext(context.Background())
   181  }
   182  
   183  func (i *PolicyTemplate) ToPolicyTemplateOutputWithContext(ctx context.Context) PolicyTemplateOutput {
   184  	return pulumi.ToOutputWithContext(ctx, i).(PolicyTemplateOutput)
   185  }
   186  
   187  // PolicyTemplateArrayInput is an input type that accepts PolicyTemplateArray and PolicyTemplateArrayOutput values.
   188  // You can construct a concrete instance of `PolicyTemplateArrayInput` via:
   189  //
   190  //	PolicyTemplateArray{ PolicyTemplateArgs{...} }
   191  type PolicyTemplateArrayInput interface {
   192  	pulumi.Input
   193  
   194  	ToPolicyTemplateArrayOutput() PolicyTemplateArrayOutput
   195  	ToPolicyTemplateArrayOutputWithContext(context.Context) PolicyTemplateArrayOutput
   196  }
   197  
   198  type PolicyTemplateArray []PolicyTemplateInput
   199  
   200  func (PolicyTemplateArray) ElementType() reflect.Type {
   201  	return reflect.TypeOf((*[]*PolicyTemplate)(nil)).Elem()
   202  }
   203  
   204  func (i PolicyTemplateArray) ToPolicyTemplateArrayOutput() PolicyTemplateArrayOutput {
   205  	return i.ToPolicyTemplateArrayOutputWithContext(context.Background())
   206  }
   207  
   208  func (i PolicyTemplateArray) ToPolicyTemplateArrayOutputWithContext(ctx context.Context) PolicyTemplateArrayOutput {
   209  	return pulumi.ToOutputWithContext(ctx, i).(PolicyTemplateArrayOutput)
   210  }
   211  
   212  // PolicyTemplateMapInput is an input type that accepts PolicyTemplateMap and PolicyTemplateMapOutput values.
   213  // You can construct a concrete instance of `PolicyTemplateMapInput` via:
   214  //
   215  //	PolicyTemplateMap{ "key": PolicyTemplateArgs{...} }
   216  type PolicyTemplateMapInput interface {
   217  	pulumi.Input
   218  
   219  	ToPolicyTemplateMapOutput() PolicyTemplateMapOutput
   220  	ToPolicyTemplateMapOutputWithContext(context.Context) PolicyTemplateMapOutput
   221  }
   222  
   223  type PolicyTemplateMap map[string]PolicyTemplateInput
   224  
   225  func (PolicyTemplateMap) ElementType() reflect.Type {
   226  	return reflect.TypeOf((*map[string]*PolicyTemplate)(nil)).Elem()
   227  }
   228  
   229  func (i PolicyTemplateMap) ToPolicyTemplateMapOutput() PolicyTemplateMapOutput {
   230  	return i.ToPolicyTemplateMapOutputWithContext(context.Background())
   231  }
   232  
   233  func (i PolicyTemplateMap) ToPolicyTemplateMapOutputWithContext(ctx context.Context) PolicyTemplateMapOutput {
   234  	return pulumi.ToOutputWithContext(ctx, i).(PolicyTemplateMapOutput)
   235  }
   236  
   237  type PolicyTemplateOutput struct{ *pulumi.OutputState }
   238  
   239  func (PolicyTemplateOutput) ElementType() reflect.Type {
   240  	return reflect.TypeOf((**PolicyTemplate)(nil)).Elem()
   241  }
   242  
   243  func (o PolicyTemplateOutput) ToPolicyTemplateOutput() PolicyTemplateOutput {
   244  	return o
   245  }
   246  
   247  func (o PolicyTemplateOutput) ToPolicyTemplateOutputWithContext(ctx context.Context) PolicyTemplateOutput {
   248  	return o
   249  }
   250  
   251  // The date the Policy Store was created.
   252  func (o PolicyTemplateOutput) CreatedDate() pulumi.StringOutput {
   253  	return o.ApplyT(func(v *PolicyTemplate) pulumi.StringOutput { return v.CreatedDate }).(pulumi.StringOutput)
   254  }
   255  
   256  // Provides a description for the policy template.
   257  func (o PolicyTemplateOutput) Description() pulumi.StringPtrOutput {
   258  	return o.ApplyT(func(v *PolicyTemplate) pulumi.StringPtrOutput { return v.Description }).(pulumi.StringPtrOutput)
   259  }
   260  
   261  // The ID of the Policy Store.
   262  func (o PolicyTemplateOutput) PolicyStoreId() pulumi.StringOutput {
   263  	return o.ApplyT(func(v *PolicyTemplate) pulumi.StringOutput { return v.PolicyStoreId }).(pulumi.StringOutput)
   264  }
   265  
   266  // The ID of the Policy Store.
   267  func (o PolicyTemplateOutput) PolicyTemplateId() pulumi.StringOutput {
   268  	return o.ApplyT(func(v *PolicyTemplate) pulumi.StringOutput { return v.PolicyTemplateId }).(pulumi.StringOutput)
   269  }
   270  
   271  // Defines the content of the statement, written in Cedar policy language.
   272  //
   273  // The following arguments are optional:
   274  func (o PolicyTemplateOutput) Statement() pulumi.StringOutput {
   275  	return o.ApplyT(func(v *PolicyTemplate) pulumi.StringOutput { return v.Statement }).(pulumi.StringOutput)
   276  }
   277  
   278  type PolicyTemplateArrayOutput struct{ *pulumi.OutputState }
   279  
   280  func (PolicyTemplateArrayOutput) ElementType() reflect.Type {
   281  	return reflect.TypeOf((*[]*PolicyTemplate)(nil)).Elem()
   282  }
   283  
   284  func (o PolicyTemplateArrayOutput) ToPolicyTemplateArrayOutput() PolicyTemplateArrayOutput {
   285  	return o
   286  }
   287  
   288  func (o PolicyTemplateArrayOutput) ToPolicyTemplateArrayOutputWithContext(ctx context.Context) PolicyTemplateArrayOutput {
   289  	return o
   290  }
   291  
   292  func (o PolicyTemplateArrayOutput) Index(i pulumi.IntInput) PolicyTemplateOutput {
   293  	return pulumi.All(o, i).ApplyT(func(vs []interface{}) *PolicyTemplate {
   294  		return vs[0].([]*PolicyTemplate)[vs[1].(int)]
   295  	}).(PolicyTemplateOutput)
   296  }
   297  
   298  type PolicyTemplateMapOutput struct{ *pulumi.OutputState }
   299  
   300  func (PolicyTemplateMapOutput) ElementType() reflect.Type {
   301  	return reflect.TypeOf((*map[string]*PolicyTemplate)(nil)).Elem()
   302  }
   303  
   304  func (o PolicyTemplateMapOutput) ToPolicyTemplateMapOutput() PolicyTemplateMapOutput {
   305  	return o
   306  }
   307  
   308  func (o PolicyTemplateMapOutput) ToPolicyTemplateMapOutputWithContext(ctx context.Context) PolicyTemplateMapOutput {
   309  	return o
   310  }
   311  
   312  func (o PolicyTemplateMapOutput) MapIndex(k pulumi.StringInput) PolicyTemplateOutput {
   313  	return pulumi.All(o, k).ApplyT(func(vs []interface{}) *PolicyTemplate {
   314  		return vs[0].(map[string]*PolicyTemplate)[vs[1].(string)]
   315  	}).(PolicyTemplateOutput)
   316  }
   317  
   318  func init() {
   319  	pulumi.RegisterInputType(reflect.TypeOf((*PolicyTemplateInput)(nil)).Elem(), &PolicyTemplate{})
   320  	pulumi.RegisterInputType(reflect.TypeOf((*PolicyTemplateArrayInput)(nil)).Elem(), PolicyTemplateArray{})
   321  	pulumi.RegisterInputType(reflect.TypeOf((*PolicyTemplateMapInput)(nil)).Elem(), PolicyTemplateMap{})
   322  	pulumi.RegisterOutputType(PolicyTemplateOutput{})
   323  	pulumi.RegisterOutputType(PolicyTemplateArrayOutput{})
   324  	pulumi.RegisterOutputType(PolicyTemplateMapOutput{})
   325  }