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

Lambda S3 object version defaults to $LATEST if unspecified #4770

Closed
wants to merge 3 commits into from
Closed

Lambda S3 object version defaults to $LATEST if unspecified #4770

wants to merge 3 commits into from

Conversation

Bowbaq
Copy link
Contributor

@Bowbaq Bowbaq commented Jan 21, 2016

Turns out S3ObjectVersion is not required by the S3 API. Since there's no way to get an object's version in terraform (afaik), it's useful to be able to leave it out.

@radeksimko radeksimko changed the title S3 object version defaults to $LATEST if unspecified Lambda S3 object version defaults to $LATEST if unspecified Jan 21, 2016
@radeksimko
Copy link
Member

When you don't specify the version in the API, it is set to $LATEST by default, right?
So I assume this is just to avoid the following as it's default behaviour?

resource "aws_lambda_function" "test" {
    ...
    s3_object_version = "$LATEST"
    ...
}

It would be nice to have an acceptance test confirming this behaviour.

Otherwise I'm happy to merge this, but I'd hold off until we merge #3825

@radeksimko radeksimko added the waiting-response An issue/pull request is waiting for a response from the community label Jan 28, 2016
@Bowbaq
Copy link
Contributor Author

Bowbaq commented Jan 28, 2016

If I recall, you can only explicitly set a 'proper' object version, and $LATEST isn't valid. I'll see if I can write a test tomorrow (haven't gotten round to looking at the test infrastructure yet)

@radeksimko radeksimko removed the waiting-response An issue/pull request is waiting for a response from the community label Jan 28, 2016
@radeksimko
Copy link
Member

Understood, I wonder what comes back from the GetFunction API endpoint after not specifying the version in CreateFunction - $LATEST or empty string?

If user decides to manage versions outside of terraform, yet still reference/output/display current version we also may want to make s3_object_version Computed and read it back from the API.

Ping me if you need any help with writing the test.

@Bowbaq
Copy link
Contributor Author

Bowbaq commented Feb 1, 2016

@radeksimko pretty busy these days, it's probably going to take a couple more days before I can get around to finishing this up

@radeksimko
Copy link
Member

No problem, I'm also busy, currently Fosdem + CfgMgmt Camp, I'll probably get back to Lambda PRs by the end of this week.

@Bowbaq
Copy link
Contributor Author

Bowbaq commented Feb 3, 2016

@radeksimko I took a stab at it, lmk

if strings.HasSuffix(fname, "s3") && *c.Version != "$LATEST" {
return fmt.Errorf("Expected version $LATEST, got %s", *c.Version)
}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be nice to separate this function out into more generic ones instead of hardcoding values, e.g.

  • testAccCheckAWSLambdaFunctionName(expectedName string, function *lambda.GetFunctionOutput)
  • testAccCheckAWSLambdaFunctionVersion(expectedVersion string, function *lambda.GetFunctionOutput)

@radeksimko
Copy link
Member

Except the nitpick in the acceptance test case this is looking good. 👍

I spent some time reading the Lambda docs, specifically the part about versioning and I'd like to note though that s3_object_version and that version which has $LATEST are two different things. There doesn't seem to be an easy way to get s3_object_version back from the API. Version attribute can either be an alias or a version which has been published when uploading a new zip file or bumping the s3_object_version.

i.e. That acceptance test doesn't do any harm, it tests the schema at least, but checking $LATEST in the context of omitting s3_object_version is irrelevant since you can get Version=$LATEST even if the user submits s3_object_version=specificVersionID.

We don't expose Version as version nor we publish versions (yet) and updating code in place works without it, so it's not really an issue, but I wanted to clarify this.

@Bowbaq
Copy link
Contributor Author

Bowbaq commented Feb 8, 2016

@radeksimko refactored as per your comments. I don't have too much more time to put in this, so feel free to fork & make any necessary edits

@radeksimko
Copy link
Member

Thanks for the modifications.

I don't have too much more time to put in this, so feel free to fork & make any necessary edits

No problem, I think this now looks ok on the first sight. I will do a final review by the end of this week, after #3825 is merged.

@leetrout
Copy link

@radeksimko is this blocked by #3825?

@radeksimko
Copy link
Member

@leetrout I reran Travis tests and that brought up some failures, but I'll fix this and merge in separately, before #3825 , or #5239 respectively is merged. This PR looks like smaller thing that can sneak in and I can resolve any conflicts with #5239 afterwards.

@radeksimko
Copy link
Member

Merged via #5370

@ghost
Copy link

ghost commented Apr 27, 2020

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@ghost ghost locked and limited conversation to collaborators Apr 27, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants