Skip to content

Commit

Permalink
cli package terraform support
Browse files Browse the repository at this point in the history
  • Loading branch information
kapilt committed May 27, 2019
1 parent 0ad94ee commit c1dfa13
Show file tree
Hide file tree
Showing 7 changed files with 786 additions and 64 deletions.
8 changes: 5 additions & 3 deletions chalice/cli/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -374,13 +374,15 @@ def generate_sdk(ctx, sdk_type, stage, outdir):
"this argument is specified, a single "
"zip file will be created instead."))
@click.option('--stage', default=DEFAULT_STAGE_NAME)
@click.option('--pkg-format', default='cloudformation',
type=click.Choice(['cloudformation', 'terraform']))
@click.argument('out')
@click.pass_context
def package(ctx, single_file, stage, out):
# type: (click.Context, bool, str, str) -> None
def package(ctx, single_file, stage, out, pkg_format='cloudformation'):
# type: (click.Context, bool, str, str, str) -> None
factory = ctx.obj['factory'] # type: CLIFactory
config = factory.create_config_obj(stage)
packager = factory.create_app_packager(config)
packager = factory.create_app_packager(config, pkg_format)
if single_file:
dirname = tempfile.mkdtemp()
try:
Expand Down
6 changes: 3 additions & 3 deletions chalice/cli/factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,9 +177,9 @@ def _validate_config_from_disk(self, config):
except ValueError:
raise UnknownConfigFileVersion(string_version)

def create_app_packager(self, config):
# type: (Config) -> AppPackager
return create_app_packager(config)
def create_app_packager(self, config, package_format):
# type: (Config, str) -> AppPackager
return create_app_packager(config, package_format)

def create_log_retriever(self, session, lambda_arn):
# type: (Session, str) -> LogRetriever
Expand Down
15 changes: 15 additions & 0 deletions chalice/deploy/swagger.py
Original file line number Diff line number Diff line change
Expand Up @@ -279,3 +279,18 @@ def _auth_uri(self, authorizer):
'/functions/{%s}/invocations' % varname,
['region_name', varname],
)


class TerraformSwaggerGenerator(SwaggerGenerator):

def __init__(self):
# type: () -> None
pass

def _uri(self, lambda_arn=None):
# type: (Optional[str]) -> Any
return '${aws_lambda_function.api_handler.invoke_arn}'

def _auth_uri(self, authorizer):
# type: (ChaliceAuthorizer) -> Any
return '${aws_lambda_function.%s.invoke_arn}' % (authorizer.name)
Loading

0 comments on commit c1dfa13

Please sign in to comment.