github.com/pulumi/pulumi-aws/sdk/v6@v6.32.0/go/aws/lambda/layerVersionPermission.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 lambda
     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  // Provides a Lambda Layer Version Permission resource. It allows you to share you own Lambda Layers to another account by account ID, to all accounts in AWS organization or even to all AWS accounts.
    16  //
    17  // For information about Lambda Layer Permissions and how to use them, see [Using Resource-based Policies for AWS Lambda][1]
    18  //
    19  // > **NOTE:** Setting `skipDestroy` to `true` means that the AWS Provider will _not_ destroy any layer version permission, even when running `pulumi destroy`. Layer version permissions are thus intentional dangling resources that are _not_ managed by Pulumi and may incur extra expense in your AWS account.
    20  //
    21  // ## Example Usage
    22  //
    23  // <!--Start PulumiCodeChooser -->
    24  // ```go
    25  // package main
    26  //
    27  // import (
    28  //
    29  //	"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/lambda"
    30  //	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    31  //
    32  // )
    33  //
    34  //	func main() {
    35  //		pulumi.Run(func(ctx *pulumi.Context) error {
    36  //			_, err := lambda.NewLayerVersionPermission(ctx, "lambda_layer_permission", &lambda.LayerVersionPermissionArgs{
    37  //				LayerName:     pulumi.String("arn:aws:lambda:us-west-2:123456654321:layer:test_layer1"),
    38  //				VersionNumber: pulumi.Int(1),
    39  //				Principal:     pulumi.String("111111111111"),
    40  //				Action:        pulumi.String("lambda:GetLayerVersion"),
    41  //				StatementId:   pulumi.String("dev-account"),
    42  //			})
    43  //			if err != nil {
    44  //				return err
    45  //			}
    46  //			return nil
    47  //		})
    48  //	}
    49  //
    50  // ```
    51  // <!--End PulumiCodeChooser -->
    52  //
    53  // ## Import
    54  //
    55  // Using `pulumi import`, import Lambda Layer Permissions using `layer_name` and `version_number`, separated by a comma (`,`). For example:
    56  //
    57  // ```sh
    58  // $ pulumi import aws:lambda/layerVersionPermission:LayerVersionPermission example arn:aws:lambda:us-west-2:123456654321:layer:test_layer1,1
    59  // ```
    60  type LayerVersionPermission struct {
    61  	pulumi.CustomResourceState
    62  
    63  	// Action, which will be allowed. `lambda:GetLayerVersion` value is suggested by AWS documantation.
    64  	Action pulumi.StringOutput `pulumi:"action"`
    65  	// The name or ARN of the Lambda Layer, which you want to grant access to.
    66  	LayerName pulumi.StringOutput `pulumi:"layerName"`
    67  	// An identifier of AWS Organization, which should be able to use your Lambda Layer. `principal` should be equal to `*` if `organizationId` provided.
    68  	OrganizationId pulumi.StringPtrOutput `pulumi:"organizationId"`
    69  	// Full Lambda Layer Permission policy.
    70  	Policy pulumi.StringOutput `pulumi:"policy"`
    71  	// AWS account ID which should be able to use your Lambda Layer. `*` can be used here, if you want to share your Lambda Layer widely.
    72  	Principal pulumi.StringOutput `pulumi:"principal"`
    73  	// A unique identifier for the current revision of the policy.
    74  	RevisionId pulumi.StringOutput `pulumi:"revisionId"`
    75  	// Whether to retain the old version of a previously deployed Lambda Layer. Default is `false`. When this is not set to `true`, changing any of `compatibleArchitectures`, `compatibleRuntimes`, `description`, `filename`, `layerName`, `licenseInfo`, `s3Bucket`, `s3Key`, `s3ObjectVersion`, or `sourceCodeHash` forces deletion of the existing layer version and creation of a new layer version.
    76  	SkipDestroy pulumi.BoolPtrOutput `pulumi:"skipDestroy"`
    77  	// The name of Lambda Layer Permission, for example `dev-account` - human readable note about what is this permission for.
    78  	StatementId pulumi.StringOutput `pulumi:"statementId"`
    79  	// Version of Lambda Layer, which you want to grant access to. Note: permissions only apply to a single version of a layer.
    80  	VersionNumber pulumi.IntOutput `pulumi:"versionNumber"`
    81  }
    82  
    83  // NewLayerVersionPermission registers a new resource with the given unique name, arguments, and options.
    84  func NewLayerVersionPermission(ctx *pulumi.Context,
    85  	name string, args *LayerVersionPermissionArgs, opts ...pulumi.ResourceOption) (*LayerVersionPermission, error) {
    86  	if args == nil {
    87  		return nil, errors.New("missing one or more required arguments")
    88  	}
    89  
    90  	if args.Action == nil {
    91  		return nil, errors.New("invalid value for required argument 'Action'")
    92  	}
    93  	if args.LayerName == nil {
    94  		return nil, errors.New("invalid value for required argument 'LayerName'")
    95  	}
    96  	if args.Principal == nil {
    97  		return nil, errors.New("invalid value for required argument 'Principal'")
    98  	}
    99  	if args.StatementId == nil {
   100  		return nil, errors.New("invalid value for required argument 'StatementId'")
   101  	}
   102  	if args.VersionNumber == nil {
   103  		return nil, errors.New("invalid value for required argument 'VersionNumber'")
   104  	}
   105  	opts = internal.PkgResourceDefaultOpts(opts)
   106  	var resource LayerVersionPermission
   107  	err := ctx.RegisterResource("aws:lambda/layerVersionPermission:LayerVersionPermission", name, args, &resource, opts...)
   108  	if err != nil {
   109  		return nil, err
   110  	}
   111  	return &resource, nil
   112  }
   113  
   114  // GetLayerVersionPermission gets an existing LayerVersionPermission resource's state with the given name, ID, and optional
   115  // state properties that are used to uniquely qualify the lookup (nil if not required).
   116  func GetLayerVersionPermission(ctx *pulumi.Context,
   117  	name string, id pulumi.IDInput, state *LayerVersionPermissionState, opts ...pulumi.ResourceOption) (*LayerVersionPermission, error) {
   118  	var resource LayerVersionPermission
   119  	err := ctx.ReadResource("aws:lambda/layerVersionPermission:LayerVersionPermission", name, id, state, &resource, opts...)
   120  	if err != nil {
   121  		return nil, err
   122  	}
   123  	return &resource, nil
   124  }
   125  
   126  // Input properties used for looking up and filtering LayerVersionPermission resources.
   127  type layerVersionPermissionState struct {
   128  	// Action, which will be allowed. `lambda:GetLayerVersion` value is suggested by AWS documantation.
   129  	Action *string `pulumi:"action"`
   130  	// The name or ARN of the Lambda Layer, which you want to grant access to.
   131  	LayerName *string `pulumi:"layerName"`
   132  	// An identifier of AWS Organization, which should be able to use your Lambda Layer. `principal` should be equal to `*` if `organizationId` provided.
   133  	OrganizationId *string `pulumi:"organizationId"`
   134  	// Full Lambda Layer Permission policy.
   135  	Policy *string `pulumi:"policy"`
   136  	// AWS account ID which should be able to use your Lambda Layer. `*` can be used here, if you want to share your Lambda Layer widely.
   137  	Principal *string `pulumi:"principal"`
   138  	// A unique identifier for the current revision of the policy.
   139  	RevisionId *string `pulumi:"revisionId"`
   140  	// Whether to retain the old version of a previously deployed Lambda Layer. Default is `false`. When this is not set to `true`, changing any of `compatibleArchitectures`, `compatibleRuntimes`, `description`, `filename`, `layerName`, `licenseInfo`, `s3Bucket`, `s3Key`, `s3ObjectVersion`, or `sourceCodeHash` forces deletion of the existing layer version and creation of a new layer version.
   141  	SkipDestroy *bool `pulumi:"skipDestroy"`
   142  	// The name of Lambda Layer Permission, for example `dev-account` - human readable note about what is this permission for.
   143  	StatementId *string `pulumi:"statementId"`
   144  	// Version of Lambda Layer, which you want to grant access to. Note: permissions only apply to a single version of a layer.
   145  	VersionNumber *int `pulumi:"versionNumber"`
   146  }
   147  
   148  type LayerVersionPermissionState struct {
   149  	// Action, which will be allowed. `lambda:GetLayerVersion` value is suggested by AWS documantation.
   150  	Action pulumi.StringPtrInput
   151  	// The name or ARN of the Lambda Layer, which you want to grant access to.
   152  	LayerName pulumi.StringPtrInput
   153  	// An identifier of AWS Organization, which should be able to use your Lambda Layer. `principal` should be equal to `*` if `organizationId` provided.
   154  	OrganizationId pulumi.StringPtrInput
   155  	// Full Lambda Layer Permission policy.
   156  	Policy pulumi.StringPtrInput
   157  	// AWS account ID which should be able to use your Lambda Layer. `*` can be used here, if you want to share your Lambda Layer widely.
   158  	Principal pulumi.StringPtrInput
   159  	// A unique identifier for the current revision of the policy.
   160  	RevisionId pulumi.StringPtrInput
   161  	// Whether to retain the old version of a previously deployed Lambda Layer. Default is `false`. When this is not set to `true`, changing any of `compatibleArchitectures`, `compatibleRuntimes`, `description`, `filename`, `layerName`, `licenseInfo`, `s3Bucket`, `s3Key`, `s3ObjectVersion`, or `sourceCodeHash` forces deletion of the existing layer version and creation of a new layer version.
   162  	SkipDestroy pulumi.BoolPtrInput
   163  	// The name of Lambda Layer Permission, for example `dev-account` - human readable note about what is this permission for.
   164  	StatementId pulumi.StringPtrInput
   165  	// Version of Lambda Layer, which you want to grant access to. Note: permissions only apply to a single version of a layer.
   166  	VersionNumber pulumi.IntPtrInput
   167  }
   168  
   169  func (LayerVersionPermissionState) ElementType() reflect.Type {
   170  	return reflect.TypeOf((*layerVersionPermissionState)(nil)).Elem()
   171  }
   172  
   173  type layerVersionPermissionArgs struct {
   174  	// Action, which will be allowed. `lambda:GetLayerVersion` value is suggested by AWS documantation.
   175  	Action string `pulumi:"action"`
   176  	// The name or ARN of the Lambda Layer, which you want to grant access to.
   177  	LayerName string `pulumi:"layerName"`
   178  	// An identifier of AWS Organization, which should be able to use your Lambda Layer. `principal` should be equal to `*` if `organizationId` provided.
   179  	OrganizationId *string `pulumi:"organizationId"`
   180  	// AWS account ID which should be able to use your Lambda Layer. `*` can be used here, if you want to share your Lambda Layer widely.
   181  	Principal string `pulumi:"principal"`
   182  	// Whether to retain the old version of a previously deployed Lambda Layer. Default is `false`. When this is not set to `true`, changing any of `compatibleArchitectures`, `compatibleRuntimes`, `description`, `filename`, `layerName`, `licenseInfo`, `s3Bucket`, `s3Key`, `s3ObjectVersion`, or `sourceCodeHash` forces deletion of the existing layer version and creation of a new layer version.
   183  	SkipDestroy *bool `pulumi:"skipDestroy"`
   184  	// The name of Lambda Layer Permission, for example `dev-account` - human readable note about what is this permission for.
   185  	StatementId string `pulumi:"statementId"`
   186  	// Version of Lambda Layer, which you want to grant access to. Note: permissions only apply to a single version of a layer.
   187  	VersionNumber int `pulumi:"versionNumber"`
   188  }
   189  
   190  // The set of arguments for constructing a LayerVersionPermission resource.
   191  type LayerVersionPermissionArgs struct {
   192  	// Action, which will be allowed. `lambda:GetLayerVersion` value is suggested by AWS documantation.
   193  	Action pulumi.StringInput
   194  	// The name or ARN of the Lambda Layer, which you want to grant access to.
   195  	LayerName pulumi.StringInput
   196  	// An identifier of AWS Organization, which should be able to use your Lambda Layer. `principal` should be equal to `*` if `organizationId` provided.
   197  	OrganizationId pulumi.StringPtrInput
   198  	// AWS account ID which should be able to use your Lambda Layer. `*` can be used here, if you want to share your Lambda Layer widely.
   199  	Principal pulumi.StringInput
   200  	// Whether to retain the old version of a previously deployed Lambda Layer. Default is `false`. When this is not set to `true`, changing any of `compatibleArchitectures`, `compatibleRuntimes`, `description`, `filename`, `layerName`, `licenseInfo`, `s3Bucket`, `s3Key`, `s3ObjectVersion`, or `sourceCodeHash` forces deletion of the existing layer version and creation of a new layer version.
   201  	SkipDestroy pulumi.BoolPtrInput
   202  	// The name of Lambda Layer Permission, for example `dev-account` - human readable note about what is this permission for.
   203  	StatementId pulumi.StringInput
   204  	// Version of Lambda Layer, which you want to grant access to. Note: permissions only apply to a single version of a layer.
   205  	VersionNumber pulumi.IntInput
   206  }
   207  
   208  func (LayerVersionPermissionArgs) ElementType() reflect.Type {
   209  	return reflect.TypeOf((*layerVersionPermissionArgs)(nil)).Elem()
   210  }
   211  
   212  type LayerVersionPermissionInput interface {
   213  	pulumi.Input
   214  
   215  	ToLayerVersionPermissionOutput() LayerVersionPermissionOutput
   216  	ToLayerVersionPermissionOutputWithContext(ctx context.Context) LayerVersionPermissionOutput
   217  }
   218  
   219  func (*LayerVersionPermission) ElementType() reflect.Type {
   220  	return reflect.TypeOf((**LayerVersionPermission)(nil)).Elem()
   221  }
   222  
   223  func (i *LayerVersionPermission) ToLayerVersionPermissionOutput() LayerVersionPermissionOutput {
   224  	return i.ToLayerVersionPermissionOutputWithContext(context.Background())
   225  }
   226  
   227  func (i *LayerVersionPermission) ToLayerVersionPermissionOutputWithContext(ctx context.Context) LayerVersionPermissionOutput {
   228  	return pulumi.ToOutputWithContext(ctx, i).(LayerVersionPermissionOutput)
   229  }
   230  
   231  // LayerVersionPermissionArrayInput is an input type that accepts LayerVersionPermissionArray and LayerVersionPermissionArrayOutput values.
   232  // You can construct a concrete instance of `LayerVersionPermissionArrayInput` via:
   233  //
   234  //	LayerVersionPermissionArray{ LayerVersionPermissionArgs{...} }
   235  type LayerVersionPermissionArrayInput interface {
   236  	pulumi.Input
   237  
   238  	ToLayerVersionPermissionArrayOutput() LayerVersionPermissionArrayOutput
   239  	ToLayerVersionPermissionArrayOutputWithContext(context.Context) LayerVersionPermissionArrayOutput
   240  }
   241  
   242  type LayerVersionPermissionArray []LayerVersionPermissionInput
   243  
   244  func (LayerVersionPermissionArray) ElementType() reflect.Type {
   245  	return reflect.TypeOf((*[]*LayerVersionPermission)(nil)).Elem()
   246  }
   247  
   248  func (i LayerVersionPermissionArray) ToLayerVersionPermissionArrayOutput() LayerVersionPermissionArrayOutput {
   249  	return i.ToLayerVersionPermissionArrayOutputWithContext(context.Background())
   250  }
   251  
   252  func (i LayerVersionPermissionArray) ToLayerVersionPermissionArrayOutputWithContext(ctx context.Context) LayerVersionPermissionArrayOutput {
   253  	return pulumi.ToOutputWithContext(ctx, i).(LayerVersionPermissionArrayOutput)
   254  }
   255  
   256  // LayerVersionPermissionMapInput is an input type that accepts LayerVersionPermissionMap and LayerVersionPermissionMapOutput values.
   257  // You can construct a concrete instance of `LayerVersionPermissionMapInput` via:
   258  //
   259  //	LayerVersionPermissionMap{ "key": LayerVersionPermissionArgs{...} }
   260  type LayerVersionPermissionMapInput interface {
   261  	pulumi.Input
   262  
   263  	ToLayerVersionPermissionMapOutput() LayerVersionPermissionMapOutput
   264  	ToLayerVersionPermissionMapOutputWithContext(context.Context) LayerVersionPermissionMapOutput
   265  }
   266  
   267  type LayerVersionPermissionMap map[string]LayerVersionPermissionInput
   268  
   269  func (LayerVersionPermissionMap) ElementType() reflect.Type {
   270  	return reflect.TypeOf((*map[string]*LayerVersionPermission)(nil)).Elem()
   271  }
   272  
   273  func (i LayerVersionPermissionMap) ToLayerVersionPermissionMapOutput() LayerVersionPermissionMapOutput {
   274  	return i.ToLayerVersionPermissionMapOutputWithContext(context.Background())
   275  }
   276  
   277  func (i LayerVersionPermissionMap) ToLayerVersionPermissionMapOutputWithContext(ctx context.Context) LayerVersionPermissionMapOutput {
   278  	return pulumi.ToOutputWithContext(ctx, i).(LayerVersionPermissionMapOutput)
   279  }
   280  
   281  type LayerVersionPermissionOutput struct{ *pulumi.OutputState }
   282  
   283  func (LayerVersionPermissionOutput) ElementType() reflect.Type {
   284  	return reflect.TypeOf((**LayerVersionPermission)(nil)).Elem()
   285  }
   286  
   287  func (o LayerVersionPermissionOutput) ToLayerVersionPermissionOutput() LayerVersionPermissionOutput {
   288  	return o
   289  }
   290  
   291  func (o LayerVersionPermissionOutput) ToLayerVersionPermissionOutputWithContext(ctx context.Context) LayerVersionPermissionOutput {
   292  	return o
   293  }
   294  
   295  // Action, which will be allowed. `lambda:GetLayerVersion` value is suggested by AWS documantation.
   296  func (o LayerVersionPermissionOutput) Action() pulumi.StringOutput {
   297  	return o.ApplyT(func(v *LayerVersionPermission) pulumi.StringOutput { return v.Action }).(pulumi.StringOutput)
   298  }
   299  
   300  // The name or ARN of the Lambda Layer, which you want to grant access to.
   301  func (o LayerVersionPermissionOutput) LayerName() pulumi.StringOutput {
   302  	return o.ApplyT(func(v *LayerVersionPermission) pulumi.StringOutput { return v.LayerName }).(pulumi.StringOutput)
   303  }
   304  
   305  // An identifier of AWS Organization, which should be able to use your Lambda Layer. `principal` should be equal to `*` if `organizationId` provided.
   306  func (o LayerVersionPermissionOutput) OrganizationId() pulumi.StringPtrOutput {
   307  	return o.ApplyT(func(v *LayerVersionPermission) pulumi.StringPtrOutput { return v.OrganizationId }).(pulumi.StringPtrOutput)
   308  }
   309  
   310  // Full Lambda Layer Permission policy.
   311  func (o LayerVersionPermissionOutput) Policy() pulumi.StringOutput {
   312  	return o.ApplyT(func(v *LayerVersionPermission) pulumi.StringOutput { return v.Policy }).(pulumi.StringOutput)
   313  }
   314  
   315  // AWS account ID which should be able to use your Lambda Layer. `*` can be used here, if you want to share your Lambda Layer widely.
   316  func (o LayerVersionPermissionOutput) Principal() pulumi.StringOutput {
   317  	return o.ApplyT(func(v *LayerVersionPermission) pulumi.StringOutput { return v.Principal }).(pulumi.StringOutput)
   318  }
   319  
   320  // A unique identifier for the current revision of the policy.
   321  func (o LayerVersionPermissionOutput) RevisionId() pulumi.StringOutput {
   322  	return o.ApplyT(func(v *LayerVersionPermission) pulumi.StringOutput { return v.RevisionId }).(pulumi.StringOutput)
   323  }
   324  
   325  // Whether to retain the old version of a previously deployed Lambda Layer. Default is `false`. When this is not set to `true`, changing any of `compatibleArchitectures`, `compatibleRuntimes`, `description`, `filename`, `layerName`, `licenseInfo`, `s3Bucket`, `s3Key`, `s3ObjectVersion`, or `sourceCodeHash` forces deletion of the existing layer version and creation of a new layer version.
   326  func (o LayerVersionPermissionOutput) SkipDestroy() pulumi.BoolPtrOutput {
   327  	return o.ApplyT(func(v *LayerVersionPermission) pulumi.BoolPtrOutput { return v.SkipDestroy }).(pulumi.BoolPtrOutput)
   328  }
   329  
   330  // The name of Lambda Layer Permission, for example `dev-account` - human readable note about what is this permission for.
   331  func (o LayerVersionPermissionOutput) StatementId() pulumi.StringOutput {
   332  	return o.ApplyT(func(v *LayerVersionPermission) pulumi.StringOutput { return v.StatementId }).(pulumi.StringOutput)
   333  }
   334  
   335  // Version of Lambda Layer, which you want to grant access to. Note: permissions only apply to a single version of a layer.
   336  func (o LayerVersionPermissionOutput) VersionNumber() pulumi.IntOutput {
   337  	return o.ApplyT(func(v *LayerVersionPermission) pulumi.IntOutput { return v.VersionNumber }).(pulumi.IntOutput)
   338  }
   339  
   340  type LayerVersionPermissionArrayOutput struct{ *pulumi.OutputState }
   341  
   342  func (LayerVersionPermissionArrayOutput) ElementType() reflect.Type {
   343  	return reflect.TypeOf((*[]*LayerVersionPermission)(nil)).Elem()
   344  }
   345  
   346  func (o LayerVersionPermissionArrayOutput) ToLayerVersionPermissionArrayOutput() LayerVersionPermissionArrayOutput {
   347  	return o
   348  }
   349  
   350  func (o LayerVersionPermissionArrayOutput) ToLayerVersionPermissionArrayOutputWithContext(ctx context.Context) LayerVersionPermissionArrayOutput {
   351  	return o
   352  }
   353  
   354  func (o LayerVersionPermissionArrayOutput) Index(i pulumi.IntInput) LayerVersionPermissionOutput {
   355  	return pulumi.All(o, i).ApplyT(func(vs []interface{}) *LayerVersionPermission {
   356  		return vs[0].([]*LayerVersionPermission)[vs[1].(int)]
   357  	}).(LayerVersionPermissionOutput)
   358  }
   359  
   360  type LayerVersionPermissionMapOutput struct{ *pulumi.OutputState }
   361  
   362  func (LayerVersionPermissionMapOutput) ElementType() reflect.Type {
   363  	return reflect.TypeOf((*map[string]*LayerVersionPermission)(nil)).Elem()
   364  }
   365  
   366  func (o LayerVersionPermissionMapOutput) ToLayerVersionPermissionMapOutput() LayerVersionPermissionMapOutput {
   367  	return o
   368  }
   369  
   370  func (o LayerVersionPermissionMapOutput) ToLayerVersionPermissionMapOutputWithContext(ctx context.Context) LayerVersionPermissionMapOutput {
   371  	return o
   372  }
   373  
   374  func (o LayerVersionPermissionMapOutput) MapIndex(k pulumi.StringInput) LayerVersionPermissionOutput {
   375  	return pulumi.All(o, k).ApplyT(func(vs []interface{}) *LayerVersionPermission {
   376  		return vs[0].(map[string]*LayerVersionPermission)[vs[1].(string)]
   377  	}).(LayerVersionPermissionOutput)
   378  }
   379  
   380  func init() {
   381  	pulumi.RegisterInputType(reflect.TypeOf((*LayerVersionPermissionInput)(nil)).Elem(), &LayerVersionPermission{})
   382  	pulumi.RegisterInputType(reflect.TypeOf((*LayerVersionPermissionArrayInput)(nil)).Elem(), LayerVersionPermissionArray{})
   383  	pulumi.RegisterInputType(reflect.TypeOf((*LayerVersionPermissionMapInput)(nil)).Elem(), LayerVersionPermissionMap{})
   384  	pulumi.RegisterOutputType(LayerVersionPermissionOutput{})
   385  	pulumi.RegisterOutputType(LayerVersionPermissionArrayOutput{})
   386  	pulumi.RegisterOutputType(LayerVersionPermissionMapOutput{})
   387  }