Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(late-init): Lambda Permission: statement_id_prefix late initialization problem #1004

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading