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

feat: add synth & kwargs #288

Merged
merged 4 commits into from
Feb 3, 2025
Merged

feat: add synth & kwargs #288

merged 4 commits into from
Feb 3, 2025

Conversation

kukushking
Copy link
Contributor

@kukushking kukushking commented Jan 31, 2025

Issue #, if available: #272

Description of changes:

  1. Add --synth option to deploy seedkit CLI. This will synthesize and output the seedkit template but not deploy it, to allow users to change it and deploy outside of codeseeder if required. This will allow to support customisation requirements such as adding tags, changing IAM paths or resource naming conventions.
  2. Add **kwargs escape hatch to deploy_seedkit API and support setting IAM paths via:
codeseeder.deploy_seedkit("test", role_prefix="/test/", policy_prefix="/test/")

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@kukushking kukushking requested a review from a team January 31, 2025 13:16
@kukushking kukushking self-assigned this Jan 31, 2025
) -> str:
synthesize: bool = False,
**kwargs: Dict[str, Any],
) -> Optional[str]:
Copy link

Choose a reason for hiding this comment

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

I know this function doesn't have a docstring right now, but I think it would be good to add one while we're here.

I'm skeptical on using kwargs here -- it is two extra optional parameters, but they're completely undocumented. Why not just add role_prefix and policy_prefix?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is intended. kwargs is an escape hatch and would allow us to pass any other parameters from Seed-Farmer (or any other tool) in the future without breaking backward-compatibility.

Copy link

Choose a reason for hiding this comment

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

For what value? To decouple seed-farmer and code-seeder versions slightly?

Copy link
Contributor Author

@kukushking kukushking Jan 31, 2025

Choose a reason for hiding this comment

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

Yep

@@ -96,7 +100,7 @@ def deploy_seedkit(
if stack_exists:
deploy_id = stack_outputs.get("DeployId")
LOGGER.info("Seedkit found with DeployId: %s", deploy_id)
template_filename: str = _cfn_seedkit.synth(
template_filename: Optional[str] = _cfn_seedkit.synth(
Copy link

Choose a reason for hiding this comment

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

Would it make more sense to have synth return the string template instead of the path?

Right now there's a coupling that synthesize=False changes the output value. That looks like quite a refactor though, so maybe it isn't worth it. Probably just add an assertion under if not synthesize that template_filename is non-None?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah I considered refactoring this but did not want to make too intrusive changes. Good call about an assertion though.

file.write(template)
return output_filename
else:
sys.stdout.write(template)
Copy link

Choose a reason for hiding this comment

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

Will this get mixed in with log output? Is that OK?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Redirecting this into a file i.e:

codeseeder deploy seedkit test --synth > test.yaml

Doesn't mix it up with the log output and produces a valid template

@dgraeber dgraeber merged commit bc09f99 into awslabs:main Feb 3, 2025
6 checks passed
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.

3 participants