aws-cloudformation / cloudformation-cli

The CloudFormation Provider Development Toolkit allows you to author your own resource providers and modules that can be used by CloudFormation.
Apache License 2.0
316 stars 158 forks source link

Allow specifying --[no-]-use-docker via CLI during packaging / submit #969

Closed 4naesthetic closed 1 year ago

4naesthetic commented 1 year ago

When building hooks or resources we often want to use a different build configuration on a developers desktop versus in CI. Today I can only specify whether or not builds should happen in a docker container during cfn init or by modifying the .rpdk-config file, which makes it difficult to configure developers to build using docker on their local machine but have our CI workflow build without docker, as the CI workflow may already be running in a container. I can achieve this today by writing a wrapper that injects different config depending on the build environment, but it would be much easier if I could override the use_docker flag at build / packaging time.

Example CLI usage:

# Create a new project, setting use_docker to true in the initial config
cfn init

# Validate and package using the project config (build in docker container)
cfn submit --dry-run

# Validate and package without using docker, overriding the project settings, e.g. in a CI container
cfn submit --dry-run --no-use-docker
mmaeng commented 1 year ago

Thanks for the feedback, will take a look!

mmaeng commented 1 year ago

This PR will override the setting for use_docker in .rpdk-config during the cfn submit command. Hope that works for your use case!