Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def update() -> None:
"""
Update the application files only.
"""
config, error = get_config()
if error is not None:
click.echo(error)
else:
click.echo("Updating the application build.")
config.build(update=True)
click.echo("Update complete!")
def deploy() -> None:
config, error = get_config()
if error is not None:
click.echo(error)
else:
click.echo("Deploying your application! This may take some time...")
deployed = config.cli_deploy()
if not deployed:
click.echo("There was an error...")
else:
endpoints = config.cli_describe()
click.echo(
f"Deployment successful! API endpoints available at:\n\n{endpoints}"
)
def tail() -> None:
config, error = get_config()
if error is not None:
click.echo(error)
else:
# Display the CloudWatch logs for the last 10 minutes.
# TODO: Make this configurable.
log_events = get_log_events(
f"/aws/lambda/{config.resource_name}Function", minutes=10
)
log_output = []
for log in log_events:
message = log["message"].rstrip()
if not any(
i in message
for i in ("START RequestId", "REPORT RequestId", "END RequestId")
):
timestamp = log["timestamp"]
def validate() -> None:
config, error = get_config()
if error is not None:
click.echo(error)
else:
error = config.validate()
if not error:
click.echo("Template file validated successfully!")
else:
click.echo(error)
def build() -> None:
"""
Install the packages listed in the requirements file and copy the application files
to the 'build/' directory to prepare for packaging.
"""
config, error = get_config()
if error is not None:
click.echo(error)
else:
click.echo("Building application and installing requirements...")
config.build()
click.echo("Build complete!")
def describe() -> None:
config, error = get_config()
if error is not None:
click.echo(error)
else:
endpoints = config.cli_describe()
if not endpoints:
click.echo("Error! Could not retrieve endpoints.")
else:
click.echo(f"API endpoints available at:\n\n{endpoints}")
def package() -> None:
config, error = get_config()
if error is not None:
click.echo(error)
else:
click.echo("Packaging your application...")
packaged = config.cli_package()
if not packaged:
click.echo("There was an error...")
else:
click.echo(
"Successfully packaged. Run 'mangum aws deploy' to deploy it now."
)