Skip to content

Commit

Permalink
Merge pull request #1004 from haarchri/fix/late-init-lambda-permission
Browse files Browse the repository at this point in the history
fix(late-init): Lambda Permission: statement_id_prefix late initialization problem
  • Loading branch information
turkenf authored Dec 5, 2023
2 parents f0fd50b + f0e19e8 commit 1cdb099
Show file tree
Hide file tree
Showing 3 changed files with 157 additions and 1 deletion.
1 change: 1 addition & 0 deletions apis/lambda/v1beta1/zz_generated_terraformed.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions config/lambda/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,9 @@ func Configure(p *config.Provider) {
})

p.AddResourceConfigurator("aws_lambda_permission", func(r *config.Resource) {
r.LateInitializer = config.LateInitializer{
IgnoredFields: []string{"statement_id_prefix"},
}
r.References["function_name"] = config.Reference{
Type: "Function",
}
Expand Down
154 changes: 153 additions & 1 deletion examples/lambda/permission.yaml
Original file line number Diff line number Diff line change
@@ -1,12 +1,164 @@
apiVersion: lambda.aws.upbound.io/v1beta1
kind: Permission
metadata:
annotations:
meta.upbound.io/example-id: lambda/v1beta1/permission
name: example
spec:
forProvider:
region: us-west-1
action: lambda:InvokeFunction
functionNameRef:
name: example
name: example-permission
principal: events.amazonaws.com
statementId: AllowExecutionFromCloudWatch
---
apiVersion: lambda.aws.upbound.io/v1beta1
kind: Function
metadata:
annotations:
meta.upbound.io/example-id: lambda/v1beta1/permission
uptest.upbound.io/timeout: "3600"
labels:
testing.upbound.io/example-name: example
name: example-permission
spec:
forProvider:
s3Bucket: upbound-provider-test-data
s3Key: hello-python.zip
handler: index.py
packageType: Zip
region: us-west-1
roleSelector:
matchLabels:
testing.upbound.io/example-name: role
runtime: python3.9
timeout: 60
vpcConfig:
- securityGroupIdSelector:
matchLabels:
testing.upbound.io/example-name: example
subnetIdSelector:
matchLabels:
testing.upbound.io/example-name: example
---
apiVersion: iam.aws.upbound.io/v1beta1
kind: Role
metadata:
annotations:
meta.upbound.io/example-id: lambda/v1beta1/permission
labels:
testing.upbound.io/example-name: role
name: example-permission
spec:
forProvider:
assumeRolePolicy: |
{
"Version": "2012-10-17",
"Statement": [
{
"Action": "sts:AssumeRole",
"Principal": {
"Service": ["ec2.amazonaws.com", "lambda.amazonaws.com"]
},
"Effect": "Allow",
"Sid": ""
}
]
}
---
apiVersion: iam.aws.upbound.io/v1beta1
kind: Policy
metadata:
annotations:
meta.upbound.io/example-id: lambda/v1beta1/permission
labels:
testing.upbound.io/example-name: policy
name: example-permission
spec:
forProvider:
policy: |
{
"Version": "2012-10-17",
"Statement": [
{
"Action": [
"ec2:DescribeVpcEndpoints",
"ec2:DescribeRouteTables",
"ec2:CreateNetworkInterface",
"ec2:DeleteNetworkInterface",
"ec2:DescribeSecurityGroups",
"ec2:DescribeSubnets",
"ec2:DescribeVpcAttribute",
"ec2:DescribeNetworkInterfaces"
],
"Effect": "Allow",
"Resource": "*"
}
]
}
---
apiVersion: iam.aws.upbound.io/v1beta1
kind: RolePolicyAttachment
metadata:
annotations:
meta.upbound.io/example-id: lambda/v1beta1/permission
name: example-permission
labels:
testing.upbound.io/example-name: policy-attachment
spec:
forProvider:
policyArnSelector:
matchLabels:
testing.upbound.io/example-name: policy
roleSelector:
matchLabels:
testing.upbound.io/example-name: role
---
apiVersion: ec2.aws.upbound.io/v1beta1
kind: Subnet
metadata:
annotations:
meta.upbound.io/example-id: lambda/v1beta1/permission
labels:
testing.upbound.io/example-name: example
name: example-permission
spec:
forProvider:
region: us-west-1
vpcIdRef:
name: example-permission
cidrBlock: 172.16.10.0/24
---
apiVersion: ec2.aws.upbound.io/v1beta1
kind: SecurityGroup
metadata:
annotations:
meta.upbound.io/example-id: lambda/v1beta1/permission
labels:
testing.upbound.io/example-name: example
name: example-permission
spec:
forProvider:
description: Allow TLS inbound traffic
name: allow_tls
tags:
Name: allow_tls
region: us-west-1
vpcIdRef:
name: example-permission
---
apiVersion: ec2.aws.upbound.io/v1beta1
kind: VPC
metadata:
annotations:
meta.upbound.io/example-id: lambda/v1beta1/permission
labels:
testing.upbound.io/example-name: example
name: example-permission
spec:
forProvider:
region: us-west-1
cidrBlock: 172.16.0.0/16
tags:
Name: example-permission

0 comments on commit 1cdb099

Please sign in to comment.