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

PreheatJob: fix function lookups and iam function permission #645

Merged
merged 1 commit into from May 25, 2023

Conversation

tongueroo
Copy link
Collaborator

@tongueroo tongueroo commented May 25, 2023

This is a 🐞 bug fix.
This is a πŸ™‹β€β™‚οΈ feature or enhancement.
This is a 🧐 documentation change.

  • I've added tests (if it's a bug, feature or enhancement)
  • I've adjusted the documentation (if it's a feature or enhancement)
  • The test suite passes (run bundle exec rspec to verify this)

Summary

Fixes #440

Vaguely, kinda, sorta, somewhat remember this from years ago. It's was a bit tricky to implement as using Ref, GetAtt, or Sub to refer to a Lambda Function logical id within an inline IAM policy document results in CloudFormation complaining about a Circular Dependency. To get around this, need to create 2 separate CloudFormation resources: IAM::Role and a separate IAM::Policy. It’s interesting (annoying).

Also, notes:

  • Improves prewarming and fixes bugs by looking up functions to preheat cloudformation, this generalizes it and handles long function names.
  • Create separate IAM Role and Policy to allow policies to reference lambda function without a circular dependency error.
  • This can to require a blue/green deployment. It depends if the user has user iam_policies in their code.

How to Test

Deploy an app with a name with a long enough name. IE:

Jets.application.configure do
  config.project_name = "some-very-very-really-long-super-long-app-project-name"
  # ...
end

Deploy it:

jets deploy

Confirm that really long function names that get cut off and managed by CloudFormation still produce an IAM policy that works.

Screenshots:

job iam role lambda function logs job iam role iam console

Version Changes

Major - due to need of blue/green deployments

* lookup functions to preheat cloudformation, this generalizes it and
  handles long function names
* create separate IAM Role and Policy to allow policies to reference
  lambda function without a circular dependency error
@tongueroo tongueroo merged commit 71bd9e1 into master May 25, 2023
@tongueroo tongueroo deleted the preheat-iam-role branch May 25, 2023 16:51
@tongueroo tongueroo mentioned this pull request Jun 6, 2023
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Auto-generated Job Names can lead to invalid permissions
1 participant