-
Notifications
You must be signed in to change notification settings - Fork 151
/
permission.go
748 lines (691 loc) · 33 KB
/
permission.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
// Code generated by the Pulumi Terraform Bridge (tfgen) Tool DO NOT EDIT.
// *** WARNING: Do not edit by hand unless you're certain you know what you are doing! ***
package lambda
import (
"context"
"reflect"
"errors"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
// Gives an external source (like an EventBridge Rule, SNS, or S3) permission to access the Lambda function.
//
// ## Example Usage
//
// ```go
// package main
//
// import (
//
// "encoding/json"
//
// "github.com/pulumi/pulumi-aws/sdk/v5/go/aws/iam"
// "github.com/pulumi/pulumi-aws/sdk/v5/go/aws/lambda"
// "github.com/pulumi/pulumi/sdk/v3/go/pulumi"
//
// )
//
// func main() {
// pulumi.Run(func(ctx *pulumi.Context) error {
// tmpJSON0, err := json.Marshal(map[string]interface{}{
// "Version": "2012-10-17",
// "Statement": []map[string]interface{}{
// map[string]interface{}{
// "Action": "sts:AssumeRole",
// "Effect": "Allow",
// "Sid": "",
// "Principal": map[string]interface{}{
// "Service": "lambda.amazonaws.com",
// },
// },
// },
// })
// if err != nil {
// return err
// }
// json0 := string(tmpJSON0)
// iamForLambda, err := iam.NewRole(ctx, "iamForLambda", &iam.RoleArgs{
// AssumeRolePolicy: pulumi.String(json0),
// })
// if err != nil {
// return err
// }
// testLambda, err := lambda.NewFunction(ctx, "testLambda", &lambda.FunctionArgs{
// Code: pulumi.NewFileArchive("lambdatest.zip"),
// Role: iamForLambda.Arn,
// Handler: pulumi.String("exports.handler"),
// Runtime: pulumi.String("nodejs16.x"),
// })
// if err != nil {
// return err
// }
// testAlias, err := lambda.NewAlias(ctx, "testAlias", &lambda.AliasArgs{
// Description: pulumi.String("a sample description"),
// FunctionName: testLambda.Name,
// FunctionVersion: pulumi.String("$LATEST"),
// })
// if err != nil {
// return err
// }
// _, err = lambda.NewPermission(ctx, "allowCloudwatch", &lambda.PermissionArgs{
// Action: pulumi.String("lambda:InvokeFunction"),
// Function: testLambda.Name,
// Principal: pulumi.String("events.amazonaws.com"),
// SourceArn: pulumi.String("arn:aws:events:eu-west-1:111122223333:rule/RunDaily"),
// Qualifier: testAlias.Name,
// })
// if err != nil {
// return err
// }
// return nil
// })
// }
//
// ```
// ## Usage with SNS
//
// ```go
// package main
//
// import (
//
// "encoding/json"
//
// "github.com/pulumi/pulumi-aws/sdk/v5/go/aws/iam"
// "github.com/pulumi/pulumi-aws/sdk/v5/go/aws/lambda"
// "github.com/pulumi/pulumi-aws/sdk/v5/go/aws/sns"
// "github.com/pulumi/pulumi/sdk/v3/go/pulumi"
//
// )
//
// func main() {
// pulumi.Run(func(ctx *pulumi.Context) error {
// defaultTopic, err := sns.NewTopic(ctx, "defaultTopic", nil)
// if err != nil {
// return err
// }
// tmpJSON0, err := json.Marshal(map[string]interface{}{
// "Version": "2012-10-17",
// "Statement": []map[string]interface{}{
// map[string]interface{}{
// "Action": "sts:AssumeRole",
// "Effect": "Allow",
// "Sid": "",
// "Principal": map[string]interface{}{
// "Service": "lambda.amazonaws.com",
// },
// },
// },
// })
// if err != nil {
// return err
// }
// json0 := string(tmpJSON0)
// defaultRole, err := iam.NewRole(ctx, "defaultRole", &iam.RoleArgs{
// AssumeRolePolicy: pulumi.String(json0),
// })
// if err != nil {
// return err
// }
// _, err = lambda.NewFunction(ctx, "func", &lambda.FunctionArgs{
// Code: pulumi.NewFileArchive("lambdatest.zip"),
// Role: defaultRole.Arn,
// Handler: pulumi.String("exports.handler"),
// Runtime: pulumi.String("python3.7"),
// })
// if err != nil {
// return err
// }
// _, err = lambda.NewPermission(ctx, "withSns", &lambda.PermissionArgs{
// Action: pulumi.String("lambda:InvokeFunction"),
// Function: _func.Name,
// Principal: pulumi.String("sns.amazonaws.com"),
// SourceArn: defaultTopic.Arn,
// })
// if err != nil {
// return err
// }
// _, err = sns.NewTopicSubscription(ctx, "lambda", &sns.TopicSubscriptionArgs{
// Topic: defaultTopic.Arn,
// Protocol: pulumi.String("lambda"),
// Endpoint: _func.Arn,
// })
// if err != nil {
// return err
// }
// return nil
// })
// }
//
// ```
//
// ## Specify Lambda permissions for API Gateway REST API
//
// ```go
// package main
//
// import (
//
// "fmt"
//
// "github.com/pulumi/pulumi-aws/sdk/v5/go/aws/apigateway"
// "github.com/pulumi/pulumi-aws/sdk/v5/go/aws/lambda"
// "github.com/pulumi/pulumi/sdk/v3/go/pulumi"
//
// )
//
// func main() {
// pulumi.Run(func(ctx *pulumi.Context) error {
// myDemoAPI, err := apigateway.NewRestApi(ctx, "myDemoAPI", &apigateway.RestApiArgs{
// Description: pulumi.String("This is my API for demonstration purposes"),
// })
// if err != nil {
// return err
// }
// _, err = lambda.NewPermission(ctx, "lambdaPermission", &lambda.PermissionArgs{
// Action: pulumi.String("lambda:InvokeFunction"),
// Function: pulumi.Any("MyDemoFunction"),
// Principal: pulumi.String("apigateway.amazonaws.com"),
// SourceArn: myDemoAPI.ExecutionArn.ApplyT(func(executionArn string) (string, error) {
// return fmt.Sprintf("%v/*", executionArn), nil
// }).(pulumi.StringOutput),
// })
// if err != nil {
// return err
// }
// return nil
// })
// }
//
// ```
//
// ## Usage with CloudWatch log group
//
// ```go
// package main
//
// import (
//
// "fmt"
//
// "github.com/pulumi/pulumi-aws/sdk/v5/go/aws/cloudwatch"
// "github.com/pulumi/pulumi-aws/sdk/v5/go/aws/iam"
// "github.com/pulumi/pulumi-aws/sdk/v5/go/aws/lambda"
// "github.com/pulumi/pulumi/sdk/v3/go/pulumi"
//
// )
//
// func main() {
// pulumi.Run(func(ctx *pulumi.Context) error {
// defaultLogGroup, err := cloudwatch.NewLogGroup(ctx, "defaultLogGroup", nil)
// if err != nil {
// return err
// }
// assumeRole, err := iam.GetPolicyDocument(ctx, &iam.GetPolicyDocumentArgs{
// Statements: []iam.GetPolicyDocumentStatement{
// {
// Effect: pulumi.StringRef("Allow"),
// Principals: []iam.GetPolicyDocumentStatementPrincipal{
// {
// Type: "Service",
// Identifiers: []string{
// "lambda.amazonaws.com",
// },
// },
// },
// Actions: []string{
// "sts:AssumeRole",
// },
// },
// },
// }, nil)
// if err != nil {
// return err
// }
// defaultRole, err := iam.NewRole(ctx, "defaultRole", &iam.RoleArgs{
// AssumeRolePolicy: *pulumi.String(assumeRole.Json),
// })
// if err != nil {
// return err
// }
// loggingFunction, err := lambda.NewFunction(ctx, "loggingFunction", &lambda.FunctionArgs{
// Code: pulumi.NewFileArchive("lamba_logging.zip"),
// Handler: pulumi.String("exports.handler"),
// Role: defaultRole.Arn,
// Runtime: pulumi.String("python3.7"),
// })
// if err != nil {
// return err
// }
// loggingPermission, err := lambda.NewPermission(ctx, "loggingPermission", &lambda.PermissionArgs{
// Action: pulumi.String("lambda:InvokeFunction"),
// Function: loggingFunction.Name,
// Principal: pulumi.String("logs.eu-west-1.amazonaws.com"),
// SourceArn: defaultLogGroup.Arn.ApplyT(func(arn string) (string, error) {
// return fmt.Sprintf("%v:*", arn), nil
// }).(pulumi.StringOutput),
// })
// if err != nil {
// return err
// }
// _, err = cloudwatch.NewLogSubscriptionFilter(ctx, "loggingLogSubscriptionFilter", &cloudwatch.LogSubscriptionFilterArgs{
// DestinationArn: loggingFunction.Arn,
// FilterPattern: pulumi.String(""),
// LogGroup: defaultLogGroup.Name,
// }, pulumi.DependsOn([]pulumi.Resource{
// loggingPermission,
// }))
// if err != nil {
// return err
// }
// return nil
// })
// }
//
// ```
//
// ## Example function URL cross-account invoke policy
//
// ```go
// package main
//
// import (
//
// "github.com/pulumi/pulumi-aws/sdk/v5/go/aws/lambda"
// "github.com/pulumi/pulumi/sdk/v3/go/pulumi"
//
// )
//
// func main() {
// pulumi.Run(func(ctx *pulumi.Context) error {
// _, err := lambda.NewFunctionUrl(ctx, "urlFunctionUrl", &lambda.FunctionUrlArgs{
// FunctionName: pulumi.Any(aws_lambda_function.Example.Function_name),
// AuthorizationType: pulumi.String("AWS_IAM"),
// })
// if err != nil {
// return err
// }
// _, err = lambda.NewPermission(ctx, "urlPermission", &lambda.PermissionArgs{
// Action: pulumi.String("lambda:InvokeFunctionUrl"),
// Function: pulumi.Any(aws_lambda_function.Example.Function_name),
// Principal: pulumi.String("arn:aws:iam::444455556666:role/example"),
// SourceAccount: pulumi.String("444455556666"),
// FunctionUrlAuthType: pulumi.String("AWS_IAM"),
// })
// if err != nil {
// return err
// }
// return nil
// })
// }
//
// ```
//
// ## Import
//
// Lambda permission statements can be imported using function_name/statement_id, with an optional qualifier, e.g.,
//
// ```sh
//
// $ pulumi import aws:lambda/permission:Permission test_lambda_permission my_test_lambda_function/AllowExecutionFromCloudWatch
//
// ```
//
// ```sh
//
// $ pulumi import aws:lambda/permission:Permission test_lambda_permission my_test_lambda_function:qualifier_name/AllowExecutionFromCloudWatch
//
// ```
type Permission struct {
pulumi.CustomResourceState
// The AWS Lambda action you want to allow in this statement. (e.g., `lambda:InvokeFunction`)
Action pulumi.StringOutput `pulumi:"action"`
// The Event Source Token to validate. Used with [Alexa Skills](https://developer.amazon.com/docs/custom-skills/host-a-custom-skill-as-an-aws-lambda-function.html#use-aws-cli).
EventSourceToken pulumi.StringPtrOutput `pulumi:"eventSourceToken"`
// Name of the Lambda function whose resource policy you are updating
Function pulumi.StringOutput `pulumi:"function"`
// Lambda Function URLs [authentication type](https://docs.aws.amazon.com/lambda/latest/dg/urls-auth.html). Valid values are: `AWS_IAM` or `NONE`. Only supported for `lambda:InvokeFunctionUrl` action.
FunctionUrlAuthType pulumi.StringPtrOutput `pulumi:"functionUrlAuthType"`
// The principal who is getting this permission e.g., `s3.amazonaws.com`, an AWS account ID, or AWS IAM principal, or AWS service principal such as `events.amazonaws.com` or `sns.amazonaws.com`.
Principal pulumi.StringOutput `pulumi:"principal"`
// The identifier for your organization in AWS Organizations. Use this to grant permissions to all the AWS accounts under this organization.
//
// [1]: https://developer.amazon.com/docs/custom-skills/host-a-custom-skill-as-an-aws-lambda-function.html#use-aws-cli
// [2]: https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-control-access-using-iam-policies-to-invoke-api.html
// [3]: https://docs.aws.amazon.com/lambda/latest/dg/urls-auth.html
PrincipalOrgId pulumi.StringPtrOutput `pulumi:"principalOrgId"`
// Query parameter to specify function version or alias name. The permission will then apply to the specific qualified ARN e.g., `arn:aws:lambda:aws-region:acct-id:function:function-name:2`
Qualifier pulumi.StringPtrOutput `pulumi:"qualifier"`
// This parameter is used when allowing cross-account access, or for S3 and SES. The AWS account ID (without a hyphen) of the source owner.
SourceAccount pulumi.StringPtrOutput `pulumi:"sourceAccount"`
// When the principal is an AWS service, the ARN of the specific resource within that service to grant permission to.
// Without this, any resource from `principal` will be granted permission – even if that resource is from another account.
// For S3, this should be the ARN of the S3 Bucket.
// For EventBridge events, this should be the ARN of the EventBridge Rule.
// For API Gateway, this should be the ARN of the API, as described [here](https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-control-access-using-iam-policies-to-invoke-api.html).
SourceArn pulumi.StringPtrOutput `pulumi:"sourceArn"`
// A unique statement identifier. By default generated by the provider.
StatementId pulumi.StringOutput `pulumi:"statementId"`
// A statement identifier prefix. The provider will generate a unique suffix. Conflicts with `statementId`.
StatementIdPrefix pulumi.StringOutput `pulumi:"statementIdPrefix"`
}
// NewPermission registers a new resource with the given unique name, arguments, and options.
func NewPermission(ctx *pulumi.Context,
name string, args *PermissionArgs, opts ...pulumi.ResourceOption) (*Permission, error) {
if args == nil {
return nil, errors.New("missing one or more required arguments")
}
if args.Action == nil {
return nil, errors.New("invalid value for required argument 'Action'")
}
if args.Function == nil {
return nil, errors.New("invalid value for required argument 'Function'")
}
if args.Principal == nil {
return nil, errors.New("invalid value for required argument 'Principal'")
}
var resource Permission
err := ctx.RegisterResource("aws:lambda/permission:Permission", name, args, &resource, opts...)
if err != nil {
return nil, err
}
return &resource, nil
}
// GetPermission gets an existing Permission resource's state with the given name, ID, and optional
// state properties that are used to uniquely qualify the lookup (nil if not required).
func GetPermission(ctx *pulumi.Context,
name string, id pulumi.IDInput, state *PermissionState, opts ...pulumi.ResourceOption) (*Permission, error) {
var resource Permission
err := ctx.ReadResource("aws:lambda/permission:Permission", name, id, state, &resource, opts...)
if err != nil {
return nil, err
}
return &resource, nil
}
// Input properties used for looking up and filtering Permission resources.
type permissionState struct {
// The AWS Lambda action you want to allow in this statement. (e.g., `lambda:InvokeFunction`)
Action *string `pulumi:"action"`
// The Event Source Token to validate. Used with [Alexa Skills](https://developer.amazon.com/docs/custom-skills/host-a-custom-skill-as-an-aws-lambda-function.html#use-aws-cli).
EventSourceToken *string `pulumi:"eventSourceToken"`
// Name of the Lambda function whose resource policy you are updating
Function interface{} `pulumi:"function"`
// Lambda Function URLs [authentication type](https://docs.aws.amazon.com/lambda/latest/dg/urls-auth.html). Valid values are: `AWS_IAM` or `NONE`. Only supported for `lambda:InvokeFunctionUrl` action.
FunctionUrlAuthType *string `pulumi:"functionUrlAuthType"`
// The principal who is getting this permission e.g., `s3.amazonaws.com`, an AWS account ID, or AWS IAM principal, or AWS service principal such as `events.amazonaws.com` or `sns.amazonaws.com`.
Principal *string `pulumi:"principal"`
// The identifier for your organization in AWS Organizations. Use this to grant permissions to all the AWS accounts under this organization.
//
// [1]: https://developer.amazon.com/docs/custom-skills/host-a-custom-skill-as-an-aws-lambda-function.html#use-aws-cli
// [2]: https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-control-access-using-iam-policies-to-invoke-api.html
// [3]: https://docs.aws.amazon.com/lambda/latest/dg/urls-auth.html
PrincipalOrgId *string `pulumi:"principalOrgId"`
// Query parameter to specify function version or alias name. The permission will then apply to the specific qualified ARN e.g., `arn:aws:lambda:aws-region:acct-id:function:function-name:2`
Qualifier *string `pulumi:"qualifier"`
// This parameter is used when allowing cross-account access, or for S3 and SES. The AWS account ID (without a hyphen) of the source owner.
SourceAccount *string `pulumi:"sourceAccount"`
// When the principal is an AWS service, the ARN of the specific resource within that service to grant permission to.
// Without this, any resource from `principal` will be granted permission – even if that resource is from another account.
// For S3, this should be the ARN of the S3 Bucket.
// For EventBridge events, this should be the ARN of the EventBridge Rule.
// For API Gateway, this should be the ARN of the API, as described [here](https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-control-access-using-iam-policies-to-invoke-api.html).
SourceArn *string `pulumi:"sourceArn"`
// A unique statement identifier. By default generated by the provider.
StatementId *string `pulumi:"statementId"`
// A statement identifier prefix. The provider will generate a unique suffix. Conflicts with `statementId`.
StatementIdPrefix *string `pulumi:"statementIdPrefix"`
}
type PermissionState struct {
// The AWS Lambda action you want to allow in this statement. (e.g., `lambda:InvokeFunction`)
Action pulumi.StringPtrInput
// The Event Source Token to validate. Used with [Alexa Skills](https://developer.amazon.com/docs/custom-skills/host-a-custom-skill-as-an-aws-lambda-function.html#use-aws-cli).
EventSourceToken pulumi.StringPtrInput
// Name of the Lambda function whose resource policy you are updating
Function pulumi.Input
// Lambda Function URLs [authentication type](https://docs.aws.amazon.com/lambda/latest/dg/urls-auth.html). Valid values are: `AWS_IAM` or `NONE`. Only supported for `lambda:InvokeFunctionUrl` action.
FunctionUrlAuthType pulumi.StringPtrInput
// The principal who is getting this permission e.g., `s3.amazonaws.com`, an AWS account ID, or AWS IAM principal, or AWS service principal such as `events.amazonaws.com` or `sns.amazonaws.com`.
Principal pulumi.StringPtrInput
// The identifier for your organization in AWS Organizations. Use this to grant permissions to all the AWS accounts under this organization.
//
// [1]: https://developer.amazon.com/docs/custom-skills/host-a-custom-skill-as-an-aws-lambda-function.html#use-aws-cli
// [2]: https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-control-access-using-iam-policies-to-invoke-api.html
// [3]: https://docs.aws.amazon.com/lambda/latest/dg/urls-auth.html
PrincipalOrgId pulumi.StringPtrInput
// Query parameter to specify function version or alias name. The permission will then apply to the specific qualified ARN e.g., `arn:aws:lambda:aws-region:acct-id:function:function-name:2`
Qualifier pulumi.StringPtrInput
// This parameter is used when allowing cross-account access, or for S3 and SES. The AWS account ID (without a hyphen) of the source owner.
SourceAccount pulumi.StringPtrInput
// When the principal is an AWS service, the ARN of the specific resource within that service to grant permission to.
// Without this, any resource from `principal` will be granted permission – even if that resource is from another account.
// For S3, this should be the ARN of the S3 Bucket.
// For EventBridge events, this should be the ARN of the EventBridge Rule.
// For API Gateway, this should be the ARN of the API, as described [here](https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-control-access-using-iam-policies-to-invoke-api.html).
SourceArn pulumi.StringPtrInput
// A unique statement identifier. By default generated by the provider.
StatementId pulumi.StringPtrInput
// A statement identifier prefix. The provider will generate a unique suffix. Conflicts with `statementId`.
StatementIdPrefix pulumi.StringPtrInput
}
func (PermissionState) ElementType() reflect.Type {
return reflect.TypeOf((*permissionState)(nil)).Elem()
}
type permissionArgs struct {
// The AWS Lambda action you want to allow in this statement. (e.g., `lambda:InvokeFunction`)
Action string `pulumi:"action"`
// The Event Source Token to validate. Used with [Alexa Skills](https://developer.amazon.com/docs/custom-skills/host-a-custom-skill-as-an-aws-lambda-function.html#use-aws-cli).
EventSourceToken *string `pulumi:"eventSourceToken"`
// Name of the Lambda function whose resource policy you are updating
Function interface{} `pulumi:"function"`
// Lambda Function URLs [authentication type](https://docs.aws.amazon.com/lambda/latest/dg/urls-auth.html). Valid values are: `AWS_IAM` or `NONE`. Only supported for `lambda:InvokeFunctionUrl` action.
FunctionUrlAuthType *string `pulumi:"functionUrlAuthType"`
// The principal who is getting this permission e.g., `s3.amazonaws.com`, an AWS account ID, or AWS IAM principal, or AWS service principal such as `events.amazonaws.com` or `sns.amazonaws.com`.
Principal string `pulumi:"principal"`
// The identifier for your organization in AWS Organizations. Use this to grant permissions to all the AWS accounts under this organization.
//
// [1]: https://developer.amazon.com/docs/custom-skills/host-a-custom-skill-as-an-aws-lambda-function.html#use-aws-cli
// [2]: https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-control-access-using-iam-policies-to-invoke-api.html
// [3]: https://docs.aws.amazon.com/lambda/latest/dg/urls-auth.html
PrincipalOrgId *string `pulumi:"principalOrgId"`
// Query parameter to specify function version or alias name. The permission will then apply to the specific qualified ARN e.g., `arn:aws:lambda:aws-region:acct-id:function:function-name:2`
Qualifier *string `pulumi:"qualifier"`
// This parameter is used when allowing cross-account access, or for S3 and SES. The AWS account ID (without a hyphen) of the source owner.
SourceAccount *string `pulumi:"sourceAccount"`
// When the principal is an AWS service, the ARN of the specific resource within that service to grant permission to.
// Without this, any resource from `principal` will be granted permission – even if that resource is from another account.
// For S3, this should be the ARN of the S3 Bucket.
// For EventBridge events, this should be the ARN of the EventBridge Rule.
// For API Gateway, this should be the ARN of the API, as described [here](https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-control-access-using-iam-policies-to-invoke-api.html).
SourceArn *string `pulumi:"sourceArn"`
// A unique statement identifier. By default generated by the provider.
StatementId *string `pulumi:"statementId"`
// A statement identifier prefix. The provider will generate a unique suffix. Conflicts with `statementId`.
StatementIdPrefix *string `pulumi:"statementIdPrefix"`
}
// The set of arguments for constructing a Permission resource.
type PermissionArgs struct {
// The AWS Lambda action you want to allow in this statement. (e.g., `lambda:InvokeFunction`)
Action pulumi.StringInput
// The Event Source Token to validate. Used with [Alexa Skills](https://developer.amazon.com/docs/custom-skills/host-a-custom-skill-as-an-aws-lambda-function.html#use-aws-cli).
EventSourceToken pulumi.StringPtrInput
// Name of the Lambda function whose resource policy you are updating
Function pulumi.Input
// Lambda Function URLs [authentication type](https://docs.aws.amazon.com/lambda/latest/dg/urls-auth.html). Valid values are: `AWS_IAM` or `NONE`. Only supported for `lambda:InvokeFunctionUrl` action.
FunctionUrlAuthType pulumi.StringPtrInput
// The principal who is getting this permission e.g., `s3.amazonaws.com`, an AWS account ID, or AWS IAM principal, or AWS service principal such as `events.amazonaws.com` or `sns.amazonaws.com`.
Principal pulumi.StringInput
// The identifier for your organization in AWS Organizations. Use this to grant permissions to all the AWS accounts under this organization.
//
// [1]: https://developer.amazon.com/docs/custom-skills/host-a-custom-skill-as-an-aws-lambda-function.html#use-aws-cli
// [2]: https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-control-access-using-iam-policies-to-invoke-api.html
// [3]: https://docs.aws.amazon.com/lambda/latest/dg/urls-auth.html
PrincipalOrgId pulumi.StringPtrInput
// Query parameter to specify function version or alias name. The permission will then apply to the specific qualified ARN e.g., `arn:aws:lambda:aws-region:acct-id:function:function-name:2`
Qualifier pulumi.StringPtrInput
// This parameter is used when allowing cross-account access, or for S3 and SES. The AWS account ID (without a hyphen) of the source owner.
SourceAccount pulumi.StringPtrInput
// When the principal is an AWS service, the ARN of the specific resource within that service to grant permission to.
// Without this, any resource from `principal` will be granted permission – even if that resource is from another account.
// For S3, this should be the ARN of the S3 Bucket.
// For EventBridge events, this should be the ARN of the EventBridge Rule.
// For API Gateway, this should be the ARN of the API, as described [here](https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-control-access-using-iam-policies-to-invoke-api.html).
SourceArn pulumi.StringPtrInput
// A unique statement identifier. By default generated by the provider.
StatementId pulumi.StringPtrInput
// A statement identifier prefix. The provider will generate a unique suffix. Conflicts with `statementId`.
StatementIdPrefix pulumi.StringPtrInput
}
func (PermissionArgs) ElementType() reflect.Type {
return reflect.TypeOf((*permissionArgs)(nil)).Elem()
}
type PermissionInput interface {
pulumi.Input
ToPermissionOutput() PermissionOutput
ToPermissionOutputWithContext(ctx context.Context) PermissionOutput
}
func (*Permission) ElementType() reflect.Type {
return reflect.TypeOf((**Permission)(nil)).Elem()
}
func (i *Permission) ToPermissionOutput() PermissionOutput {
return i.ToPermissionOutputWithContext(context.Background())
}
func (i *Permission) ToPermissionOutputWithContext(ctx context.Context) PermissionOutput {
return pulumi.ToOutputWithContext(ctx, i).(PermissionOutput)
}
// PermissionArrayInput is an input type that accepts PermissionArray and PermissionArrayOutput values.
// You can construct a concrete instance of `PermissionArrayInput` via:
//
// PermissionArray{ PermissionArgs{...} }
type PermissionArrayInput interface {
pulumi.Input
ToPermissionArrayOutput() PermissionArrayOutput
ToPermissionArrayOutputWithContext(context.Context) PermissionArrayOutput
}
type PermissionArray []PermissionInput
func (PermissionArray) ElementType() reflect.Type {
return reflect.TypeOf((*[]*Permission)(nil)).Elem()
}
func (i PermissionArray) ToPermissionArrayOutput() PermissionArrayOutput {
return i.ToPermissionArrayOutputWithContext(context.Background())
}
func (i PermissionArray) ToPermissionArrayOutputWithContext(ctx context.Context) PermissionArrayOutput {
return pulumi.ToOutputWithContext(ctx, i).(PermissionArrayOutput)
}
// PermissionMapInput is an input type that accepts PermissionMap and PermissionMapOutput values.
// You can construct a concrete instance of `PermissionMapInput` via:
//
// PermissionMap{ "key": PermissionArgs{...} }
type PermissionMapInput interface {
pulumi.Input
ToPermissionMapOutput() PermissionMapOutput
ToPermissionMapOutputWithContext(context.Context) PermissionMapOutput
}
type PermissionMap map[string]PermissionInput
func (PermissionMap) ElementType() reflect.Type {
return reflect.TypeOf((*map[string]*Permission)(nil)).Elem()
}
func (i PermissionMap) ToPermissionMapOutput() PermissionMapOutput {
return i.ToPermissionMapOutputWithContext(context.Background())
}
func (i PermissionMap) ToPermissionMapOutputWithContext(ctx context.Context) PermissionMapOutput {
return pulumi.ToOutputWithContext(ctx, i).(PermissionMapOutput)
}
type PermissionOutput struct{ *pulumi.OutputState }
func (PermissionOutput) ElementType() reflect.Type {
return reflect.TypeOf((**Permission)(nil)).Elem()
}
func (o PermissionOutput) ToPermissionOutput() PermissionOutput {
return o
}
func (o PermissionOutput) ToPermissionOutputWithContext(ctx context.Context) PermissionOutput {
return o
}
// The AWS Lambda action you want to allow in this statement. (e.g., `lambda:InvokeFunction`)
func (o PermissionOutput) Action() pulumi.StringOutput {
return o.ApplyT(func(v *Permission) pulumi.StringOutput { return v.Action }).(pulumi.StringOutput)
}
// The Event Source Token to validate. Used with [Alexa Skills](https://developer.amazon.com/docs/custom-skills/host-a-custom-skill-as-an-aws-lambda-function.html#use-aws-cli).
func (o PermissionOutput) EventSourceToken() pulumi.StringPtrOutput {
return o.ApplyT(func(v *Permission) pulumi.StringPtrOutput { return v.EventSourceToken }).(pulumi.StringPtrOutput)
}
// Name of the Lambda function whose resource policy you are updating
func (o PermissionOutput) Function() pulumi.StringOutput {
return o.ApplyT(func(v *Permission) pulumi.StringOutput { return v.Function }).(pulumi.StringOutput)
}
// Lambda Function URLs [authentication type](https://docs.aws.amazon.com/lambda/latest/dg/urls-auth.html). Valid values are: `AWS_IAM` or `NONE`. Only supported for `lambda:InvokeFunctionUrl` action.
func (o PermissionOutput) FunctionUrlAuthType() pulumi.StringPtrOutput {
return o.ApplyT(func(v *Permission) pulumi.StringPtrOutput { return v.FunctionUrlAuthType }).(pulumi.StringPtrOutput)
}
// The principal who is getting this permission e.g., `s3.amazonaws.com`, an AWS account ID, or AWS IAM principal, or AWS service principal such as `events.amazonaws.com` or `sns.amazonaws.com`.
func (o PermissionOutput) Principal() pulumi.StringOutput {
return o.ApplyT(func(v *Permission) pulumi.StringOutput { return v.Principal }).(pulumi.StringOutput)
}
// The identifier for your organization in AWS Organizations. Use this to grant permissions to all the AWS accounts under this organization.
//
// [1]: https://developer.amazon.com/docs/custom-skills/host-a-custom-skill-as-an-aws-lambda-function.html#use-aws-cli
// [2]: https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-control-access-using-iam-policies-to-invoke-api.html
// [3]: https://docs.aws.amazon.com/lambda/latest/dg/urls-auth.html
func (o PermissionOutput) PrincipalOrgId() pulumi.StringPtrOutput {
return o.ApplyT(func(v *Permission) pulumi.StringPtrOutput { return v.PrincipalOrgId }).(pulumi.StringPtrOutput)
}
// Query parameter to specify function version or alias name. The permission will then apply to the specific qualified ARN e.g., `arn:aws:lambda:aws-region:acct-id:function:function-name:2`
func (o PermissionOutput) Qualifier() pulumi.StringPtrOutput {
return o.ApplyT(func(v *Permission) pulumi.StringPtrOutput { return v.Qualifier }).(pulumi.StringPtrOutput)
}
// This parameter is used when allowing cross-account access, or for S3 and SES. The AWS account ID (without a hyphen) of the source owner.
func (o PermissionOutput) SourceAccount() pulumi.StringPtrOutput {
return o.ApplyT(func(v *Permission) pulumi.StringPtrOutput { return v.SourceAccount }).(pulumi.StringPtrOutput)
}
// When the principal is an AWS service, the ARN of the specific resource within that service to grant permission to.
// Without this, any resource from `principal` will be granted permission – even if that resource is from another account.
// For S3, this should be the ARN of the S3 Bucket.
// For EventBridge events, this should be the ARN of the EventBridge Rule.
// For API Gateway, this should be the ARN of the API, as described [here](https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-control-access-using-iam-policies-to-invoke-api.html).
func (o PermissionOutput) SourceArn() pulumi.StringPtrOutput {
return o.ApplyT(func(v *Permission) pulumi.StringPtrOutput { return v.SourceArn }).(pulumi.StringPtrOutput)
}
// A unique statement identifier. By default generated by the provider.
func (o PermissionOutput) StatementId() pulumi.StringOutput {
return o.ApplyT(func(v *Permission) pulumi.StringOutput { return v.StatementId }).(pulumi.StringOutput)
}
// A statement identifier prefix. The provider will generate a unique suffix. Conflicts with `statementId`.
func (o PermissionOutput) StatementIdPrefix() pulumi.StringOutput {
return o.ApplyT(func(v *Permission) pulumi.StringOutput { return v.StatementIdPrefix }).(pulumi.StringOutput)
}
type PermissionArrayOutput struct{ *pulumi.OutputState }
func (PermissionArrayOutput) ElementType() reflect.Type {
return reflect.TypeOf((*[]*Permission)(nil)).Elem()
}
func (o PermissionArrayOutput) ToPermissionArrayOutput() PermissionArrayOutput {
return o
}
func (o PermissionArrayOutput) ToPermissionArrayOutputWithContext(ctx context.Context) PermissionArrayOutput {
return o
}
func (o PermissionArrayOutput) Index(i pulumi.IntInput) PermissionOutput {
return pulumi.All(o, i).ApplyT(func(vs []interface{}) *Permission {
return vs[0].([]*Permission)[vs[1].(int)]
}).(PermissionOutput)
}
type PermissionMapOutput struct{ *pulumi.OutputState }
func (PermissionMapOutput) ElementType() reflect.Type {
return reflect.TypeOf((*map[string]*Permission)(nil)).Elem()
}
func (o PermissionMapOutput) ToPermissionMapOutput() PermissionMapOutput {
return o
}
func (o PermissionMapOutput) ToPermissionMapOutputWithContext(ctx context.Context) PermissionMapOutput {
return o
}
func (o PermissionMapOutput) MapIndex(k pulumi.StringInput) PermissionOutput {
return pulumi.All(o, k).ApplyT(func(vs []interface{}) *Permission {
return vs[0].(map[string]*Permission)[vs[1].(string)]
}).(PermissionOutput)
}
func init() {
pulumi.RegisterInputType(reflect.TypeOf((*PermissionInput)(nil)).Elem(), &Permission{})
pulumi.RegisterInputType(reflect.TypeOf((*PermissionArrayInput)(nil)).Elem(), PermissionArray{})
pulumi.RegisterInputType(reflect.TypeOf((*PermissionMapInput)(nil)).Elem(), PermissionMap{})
pulumi.RegisterOutputType(PermissionOutput{})
pulumi.RegisterOutputType(PermissionArrayOutput{})
pulumi.RegisterOutputType(PermissionMapOutput{})
}