https://pulumi.com logo
#aws
Title
# aws
b

big-account-56668

12/11/2020, 10:17 AM
Terraform does not seem to have this requirement on its
aws_lambda_function
resource as I've been able to define and use those independent of code. The code is updated separately using the AWS cli and it all seems to work the way I expect.
w

white-balloon-205

12/11/2020, 5:38 PM
Can you share how you are defining you
Function
? You may need to provide a value, but then can add
ignoreChanges
to ensure that you don't overwrite values that are being set outside of Pulumi. https://www.pulumi.com/docs/intro/concepts/programming-model/#ignorechanges
b

big-account-56668

12/11/2020, 7:02 PM
I don't see how the
ignoreChanges
option would help. My definition is
Copy code
_, err = lambda.NewFunction(ctx, "x", &lambda.FunctionArgs{
			MemorySize: pulumi.IntPtr(512),
			Timeout:    pulumi.IntPtr(15),
			Handler:    pulumi.String("handler"),
			Role:       role.Arn,
			Runtime:    pulumi.String("go1.x"),
			Environment: &lambda.FunctionEnvironmentArgs{
				Variables: pulumi.StringMap{
					"KEY": pulumi.String("value"),
				},
			},
		},
		)
If creating a function requires an initial reference to some release package, the only thing I can imagine working is if I switch to hosting the code on S3. Then the definition can reference a predictable code location that can be updated separately.
w

white-balloon-205

12/14/2020, 9:13 PM
If creating a function requires an initial reference to some release package, the only thing I can imagine working is if I switch to hosting the code on S3. Then the definition can reference a predictable code location that can be updated separately.
Yes - you do need to specify where the function source is when creating a Lambda - there are several options, but at least one of those is required. Note that specifying an S3 bucket does not mean that the Lambda automatically updates when you place new code in that bucket. You do have to actually deploy the Lambda itself again to pick up new code. All of this is not specific to Pulumi - just how Lambda itself works. If you have a process that is deploying new Lambda code outside of Pulumi though, you can use
ignoreChanges
to indicate that Pulumi does not own the desired state of this particular field, and can use any (valid) value for initial provisioning of the function.