diff --git a/samcli/commands/deploy/command.py b/samcli/commands/deploy/command.py index 4da0f09758..957ad22547 100644 --- a/samcli/commands/deploy/command.py +++ b/samcli/commands/deploy/command.py @@ -293,17 +293,19 @@ def guided_deploy( input_parameter_overrides = {} color = Colored() + start_bold = "\033[1m" + end_bold = "\033[0m" click.echo( color.yellow("\n\tSetting default arguments for 'sam deploy'\n\t=========================================") ) - stack_name = click.prompt(f"\tStack name", default=stack_name, type=click.STRING) - region = click.prompt(f"\tAWS region", default=default_region, type=click.STRING) + stack_name = click.prompt(f"\t{start_bold}Stack Name{end_bold}", default=stack_name, type=click.STRING) + region = click.prompt(f"\t{start_bold}AWS Region{end_bold}", default=default_region, type=click.STRING) if parameter_override_keys: for parameter_key, parameter_properties in parameter_override_keys.items(): input_parameter_overrides[parameter_key] = click.prompt( - f"\tParameter {parameter_key}", + f"\t{start_bold}Parameter {parameter_key}{end_bold}", default=parameter_overrides.get( parameter_key, parameter_properties.get("Default", "No default specified") ), @@ -311,21 +313,25 @@ def guided_deploy( ) click.secho("\t#Shows you resources changes to be deployed and require a 'Y' to initiate deploy") - confirm_changeset = click.confirm(f"\tConfirm changes before deploy", default=confirm_changeset) + confirm_changeset = click.confirm( + f"\t{start_bold}Confirm changes before deploy{end_bold}", default=confirm_changeset + ) click.secho("\t#SAM needs permission to be able to create roles to connect to the resources in your template") - capabilities_confirm = click.confirm(f"\tAllow SAM CLI IAM role creation", default=True) + capabilities_confirm = click.confirm(f"\t{start_bold}Allow SAM CLI IAM role creation{end_bold}", default=True) if not capabilities_confirm: input_capabilities = click.prompt( - f"\t Capabilities", default=default_capabilities, type=FuncParamType(func=_space_separated_list_func_type) + f"\t{start_bold}Capabilities{end_bold}", + default=default_capabilities, + type=FuncParamType(func=_space_separated_list_func_type), ) - save_to_config = click.confirm(f"\tSave arguments to samconfig.toml", default=True) + save_to_config = click.confirm(f"\t{start_bold}Save arguments to samconfig.toml{end_bold}", default=True) - click.echo(color.yellow("\n\tConfiguring deployment s3 bucket\n\t================================")) + click.echo(color.yellow("\n\tS3 bucket for deployments\n\t=========================")) s3_bucket = manage_stack(profile=profile, region=region) - click.echo(f"\tUsing deployment bucket: {s3_bucket}") - click.echo("\tYou may specify a different default deployment bucket in samconfig.toml") + click.echo(f"\tS3 bucket: {s3_bucket}") + click.echo("\tA different default S3 bucket can be set in /.samconfig.toml") return ( stack_name, diff --git a/samcli/commands/deploy/deploy_context.py b/samcli/commands/deploy/deploy_context.py index 58a5270387..e2aa23a058 100644 --- a/samcli/commands/deploy/deploy_context.py +++ b/samcli/commands/deploy/deploy_context.py @@ -33,7 +33,7 @@ class DeployContext: MSG_NO_EXECUTE_CHANGESET = "\nChangeset created successfully. \n" - MSG_EXECUTE_SUCCESS = "\nSuccessfully created/updated stack - {stack_name}\n" + MSG_EXECUTE_SUCCESS = "\nSuccessfully created/updated stack - {stack_name} in {region}\n" MSG_CONFIRM_CHANGESET = "Confirm deploying?" MSG_CONFIRM_CHANGESET_HEADER = "\nPreviewing CloudFormation changeset before deployment" @@ -111,6 +111,8 @@ def run(self): self.deployer = Deployer(cloudformation_client) + region = s3_client._client_config.region_name # pylint: disable=W0212 + return self.deploy( self.stack_name, template_str, @@ -121,6 +123,7 @@ def run(self): self.notification_arns, self.s3_uploader, [{"Key": key, "Value": value} for key, value in self.tags.items()] if self.tags else [], + region, self.fail_on_empty_changeset, self.confirm_changeset, ) @@ -136,6 +139,7 @@ def deploy( notification_arns, s3_uploader, tags, + region, fail_on_empty_changeset=True, confirm_changeset=False, ): @@ -163,7 +167,7 @@ def deploy( self.deployer.execute_changeset(result["Id"], stack_name) self.deployer.wait_for_execute(stack_name, changeset_type) - click.echo(self.MSG_EXECUTE_SUCCESS.format(stack_name=stack_name)) + click.echo(self.MSG_EXECUTE_SUCCESS.format(stack_name=stack_name, region=region)) except deploy_exceptions.ChangeEmptyError as ex: if fail_on_empty_changeset: diff --git a/samcli/lib/bootstrap/bootstrap.py b/samcli/lib/bootstrap/bootstrap.py index e093c0fe37..758258b63b 100644 --- a/samcli/lib/bootstrap/bootstrap.py +++ b/samcli/lib/bootstrap/bootstrap.py @@ -31,9 +31,9 @@ def _create_or_get_stack(cloudformation_client): ds_resp = cloudformation_client.describe_stacks(StackName=SAM_CLI_STACK_NAME) stacks = ds_resp["Stacks"] stack = stacks[0] - LOG.info("\tFound managed SAM CLI stack.") + LOG.info("\tLooking for SAM CLI managed stack: Found!") except ClientError: - LOG.info("\tManaged SAM CLI stack not found, creating.") + LOG.info("\tLooking for SAM CLI managed stack: Not found.") stack = _create_stack(cloudformation_client) # exceptions are not captured from subcommands # Sanity check for non-none stack? Sanity check for tag? tags = stack["Tags"] @@ -69,6 +69,7 @@ def _create_or_get_stack(cloudformation_client): def _create_stack(cloudformation_client): + LOG.info("\tCreating SAM CLI managed stack...") change_set_name = "InitialCreation" change_set_resp = cloudformation_client.create_change_set( StackName=SAM_CLI_STACK_NAME, @@ -78,7 +79,7 @@ def _create_stack(cloudformation_client): ChangeSetName=change_set_name, # this must be unique for the stack, but we only create so that's fine ) stack_id = change_set_resp["StackId"] - LOG.info("\tWaiting for managed stack change set to create.") + LOG.info("\tWaiting for managed stack change set to be created.") change_waiter = cloudformation_client.get_waiter("change_set_create_complete") change_waiter.wait( ChangeSetName=change_set_name, StackName=SAM_CLI_STACK_NAME, WaiterConfig={"Delay": 15, "MaxAttempts": 60} @@ -87,9 +88,9 @@ def _create_stack(cloudformation_client): LOG.info("\tWaiting for managed stack to be created.") stack_waiter = cloudformation_client.get_waiter("stack_create_complete") stack_waiter.wait(StackName=stack_id, WaiterConfig={"Delay": 15, "MaxAttempts": 60}) - LOG.info("\tManaged SAM CLI stack creation complete.") ds_resp = cloudformation_client.describe_stacks(StackName=SAM_CLI_STACK_NAME) stacks = ds_resp["Stacks"] + LOG.info("\tSuccessfully created SAM CLI managed stack!") return stacks[0] diff --git a/tests/unit/commands/init/test_cli.py b/tests/unit/commands/init/test_cli.py index 3c7a9b1274..90088f19b8 100644 --- a/tests/unit/commands/init/test_cli.py +++ b/tests/unit/commands/init/test_cli.py @@ -133,12 +133,14 @@ def test_init_cli_interactive_multiple_dep_mgrs(self, generate_project_patch, sd # 2: gradle as the dependency manager # test-project: response to name # N: Don't clone/update the source repo + # 1: first app template user_input = """ 1 5 2 test-project N +1 """ runner = CliRunner() result = runner.invoke(init_cmd, input=user_input)