Skip to content

Commit

Permalink
Merge pull request #521 from aws/dev
Browse files Browse the repository at this point in the history
chore: release 0.40
  • Loading branch information
philasmar authored Apr 22, 2022
2 parents c8a2542 + 164741a commit b60c3d5
Show file tree
Hide file tree
Showing 59 changed files with 1,332 additions and 150 deletions.
20 changes: 20 additions & 0 deletions .github/workflows/doc-builder.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: Publish docs via GitHub Pages
on:
push:
branches:
- main
- dev

# Allow the workflow to be triggered also manually.
workflow_dispatch:

jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
with:
python-version: 3.x
- run: pip install mkdocs-material==8.2.9
- run: mkdocs gh-deploy --force
36 changes: 36 additions & 0 deletions .github/workflows/semgrep-analysis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Semgrep

on:
# Scan changed files in PRs, block on new issues only (existing issues ignored)
pull_request:

push:
branches: ["dev", "main"]

schedule:
- cron: '23 20 * * 1'

jobs:
semgrep:
name: Scan
runs-on: ubuntu-latest
container:
image: returntocorp/semgrep
# Skip any PR created by dependabot to avoid permission issues
if: (github.actor != 'dependabot[bot]')
steps:
# Fetch project source
- uses: actions/checkout@v3

- run: semgrep scan --sarif --output=semgrep.sarif
env:
SEMGREP_RULES: >- # more at semgrep.dev/explore
p/security-audit
p/secrets
p/owasp-top-ten
- name: Upload SARIF file for GitHub Advanced Security Dashboard
uses: github/codeql-action/upload-sarif@v2
with:
sarif_file: semgrep.sarif
if: always()
1 change: 1 addition & 0 deletions .semgrepignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
testapps/
4 changes: 3 additions & 1 deletion THIRD_PARTY_LICENSES
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,9 @@ Copyright (c) 2016 Richard Morris
Copyright (c) 2016 Richard Morris
** Swashbuckle.AspNetCore.SwaggerGen ; version 6.1.2 -- https://www.nuget.org/packages/Swashbuckle.AspNetCore.SwaggerGen/
Copyright (c) 2016 Richard Morris

** mkdocs-material; version 8.2.9 -- https://pypi.org/project/mkdocs-material/
Copyright (c) 2016-2022 Martin Donath

Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
Expand Down
47 changes: 47 additions & 0 deletions mkdocs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
site_name: AWS .NET deployment tool
site_description: 'Deploy .NET applications on AWS'
site_url: 'https://aws.github.io/aws-dotnet-deploy/'
repo_name: 'aws/aws-dotnet-deploy'
repo_url: 'https://github.com/aws/aws-dotnet-deploy'
edit_uri: 'edit/main/site/content'
copyright: '© 2022, Amazon Web Services, Inc. or its affiliates. All rights reserved.'
docs_dir: 'site/content'
site_dir: 'docs'

nav:
- Overview: index.md
- Documentation:
- Getting Started:
- Pre-requisites: docs/getting-started/pre-requisites.md
- Installing the tool: docs/getting-started/installation.md
- Supported AWS computes:
- Amazon ECS: docs/aws-computes/ecs.md
- AWS Elastic Beanstalk: docs/aws-computes/beanstalk.md
- AWS App Runner: docs/aws-computes/app-runner.md
- Amazon S3: docs/aws-computes/s3.md
- Features:
- Recipe: docs/features/recipe.md
- Recommendation Engine: docs/features/recommendation-engine.md
- Deployment Project: docs/features/deployment-project.md
- Auto-generated Dockerfile: docs/features/autogen-dockerfile.md
- Tutorials:
- Deploying ASP.NET Core Application: docs/tutorials/deploy-webapp.md
- Deploying Blazor WebAssembly Application: docs/tutorials/deploy-blazorapp.md
- Deploying Console Service: docs/tutorials/deploy-console-service.md
- Deploying Console Task: docs/tutorials/deploy-console-task.md
- Pushing Image to ECS: docs/tutorials/push-image-ecr.md
- Automating Deployments: docs/tutorials/automate-deployments.md
- Listing Deployments: docs/tutorials/list-deployments.md
- Deleting Deployment: docs/tutorials/delete-deployment.md
- Troubleshooting Guide: troubleshooting-guide.md
- Contributing to the project: contributing.md

theme:
name: material
palette:
primary: white
font: false
language: en
features:
- tabs
- instant
21 changes: 21 additions & 0 deletions site/content/contributing.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
## Build and Test Documentation

### Install Material for MkDocs
Material for MkDocs is a theme for MkDocs, a static site generator geared towards (technical) project documentation. If you're familiar with Python, you can install Material for MkDocs with pip, the Python package manager.

```
pip install mkdocs-material
```
For, other installation options [see here](https://squidfunk.github.io/mkdocs-material/getting-started/)

### Deploying to a Local Server
MkDocs comes with a built-in dev-server that lets you preview your documentation as you work on it.

From the root of the project repository, run the following command:
```
mkdocs serve
```

Paste the link to the local server on a web browser to look at the documentation.

The dev-server also supports auto-reloading, and will rebuild your documentation whenever anything in the configuration file, documentation directory, or theme directory changes.
1 change: 1 addition & 0 deletions site/content/docs/aws-computes/app-runner.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
### TODO
1 change: 1 addition & 0 deletions site/content/docs/aws-computes/beanstalk.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
### TODO
1 change: 1 addition & 0 deletions site/content/docs/aws-computes/ecs.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
### TODO
1 change: 1 addition & 0 deletions site/content/docs/aws-computes/s3.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
### TODO
1 change: 1 addition & 0 deletions site/content/docs/features/autogen-dockerfile.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
### TODO
1 change: 1 addition & 0 deletions site/content/docs/features/deployment-project.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
### TODO
1 change: 1 addition & 0 deletions site/content/docs/features/recipe.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
### TODO
1 change: 1 addition & 0 deletions site/content/docs/features/recommendation-engine.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
### TODO
1 change: 1 addition & 0 deletions site/content/docs/getting-started/installation.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
### TODO
1 change: 1 addition & 0 deletions site/content/docs/getting-started/pre-requisites.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
### TODO
1 change: 1 addition & 0 deletions site/content/docs/tutorials/automate-deployments.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
### TODO
1 change: 1 addition & 0 deletions site/content/docs/tutorials/delete-deployment.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
### TODO
1 change: 1 addition & 0 deletions site/content/docs/tutorials/deploy-blazorapp.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
### TODO
1 change: 1 addition & 0 deletions site/content/docs/tutorials/deploy-console-service.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
### TODO
1 change: 1 addition & 0 deletions site/content/docs/tutorials/deploy-console-task.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
### TODO
1 change: 1 addition & 0 deletions site/content/docs/tutorials/deploy-webapp.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
### TODO
1 change: 1 addition & 0 deletions site/content/docs/tutorials/list-deployments.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
### TODO
1 change: 1 addition & 0 deletions site/content/docs/tutorials/push-image-ecr.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
### TODO
1 change: 1 addition & 0 deletions site/content/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
### TODO
1 change: 1 addition & 0 deletions site/content/troubleshooting-guide.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
### TODO
31 changes: 14 additions & 17 deletions src/AWS.Deploy.CLI/AWSUtilities.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@
using System.Threading.Tasks;
using Amazon.Runtime;
using Amazon.Runtime.CredentialManagement;
using Amazon.EC2.Model;
using System.IO;
using AWS.Deploy.CLI.Commands.CommandHandlerInput;
using AWS.Deploy.CLI.Utilities;
using AWS.Deploy.Common;
using AWS.Deploy.Common.IO;
Expand All @@ -18,7 +15,7 @@ namespace AWS.Deploy.CLI
{
public interface IAWSUtilities
{
Task<AWSCredentials> ResolveAWSCredentials(string? profileName, string? lastUsedProfileName = null);
Task<AWSCredentials> ResolveAWSCredentials(string? profileName);
string ResolveAWSRegion(string? region, string? lastRegionUsed = null);
}

Expand All @@ -38,26 +35,26 @@ public AWSUtilities(
_directoryManager = directoryManager;
}

public async Task<AWSCredentials> ResolveAWSCredentials(string? profileName, string? lastUsedProfileName = null)
public async Task<AWSCredentials> ResolveAWSCredentials(string? profileName)
{
async Task<AWSCredentials> Resolve()
{
var chain = new CredentialProfileStoreChain();

if (!string.IsNullOrEmpty(profileName) && chain.TryGetAWSCredentials(profileName, out var profileCredentials) &&
if (!string.IsNullOrEmpty(profileName))
{
if (chain.TryGetAWSCredentials(profileName, out var profileCredentials) &&
// Skip checking CanLoadCredentials for AssumeRoleAWSCredentials because it might require an MFA token and the callback hasn't been setup yet.
(profileCredentials is AssumeRoleAWSCredentials || await CanLoadCredentials(profileCredentials)))
{
_toolInteractiveService.WriteLine($"Configuring AWS Credentials from Profile {profileName}.");
return profileCredentials;
}

if (!string.IsNullOrEmpty(lastUsedProfileName) &&
chain.TryGetAWSCredentials(lastUsedProfileName, out var lastUsedCredentials) &&
await CanLoadCredentials(lastUsedCredentials))
{
_toolInteractiveService.WriteLine($"Configuring AWS Credentials with previous configured profile value {lastUsedProfileName}.");
return lastUsedCredentials;
{
_toolInteractiveService.WriteLine($"Configuring AWS Credentials from Profile {profileName}.");
return profileCredentials;
}
else
{
var message = $"Failed to get credentials for profile \"{profileName}\". Please provide a valid profile name and try again.";
throw new FailedToGetCredentialsForProfile(DeployToolErrorCode.FailedToGetCredentialsForProfile, message);
}
}

try
Expand Down
6 changes: 6 additions & 0 deletions src/AWS.Deploy.CLI/App.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@ public async Task<int> Run(string[] args)
_toolInteractiveService.WriteLine("AWS .NET deployment tool for deploying .NET Core applications to AWS.");
_toolInteractiveService.WriteLine("Project Home: https://github.com/aws/aws-dotnet-deploy");
_toolInteractiveService.WriteLine(string.Empty);
_toolInteractiveService.WriteLine("---------------------------------------------------------------------");
_toolInteractiveService.WriteLine("Deprecation Notice: The name of the AWS .NET deployment tool NuGet package will change from 'AWS.Deploy.CLI' to 'AWS.Deploy.Tools'. " +
"In order to keep receiving updates, make sure to uninstall the current dotnet tool 'AWS.Deploy.CLI' and install 'AWS.Deploy.Tools'. " +
"The NuGet package 'AWS.Deploy.CLI' will no longer receive any updates, so please make sure to install the new package 'AWS.Deploy.Tools'.");
_toolInteractiveService.WriteLine("---------------------------------------------------------------------");
_toolInteractiveService.WriteLine(string.Empty);

// if user didn't specify a command, default to help
if (args.Length == 0)
Expand Down
1 change: 0 additions & 1 deletion src/AWS.Deploy.CLI/Commands/CommandFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,6 @@ private Command BuildListCommand()
{
listCommand.Add(_optionProfile);
listCommand.Add(_optionRegion);
listCommand.Add(_optionProjectPath);
listCommand.Add(_optionDiagnosticLogging);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ public class ListCommandHandlerInput
{
public string? Profile { get; set; }
public string? Region { get; set; }
public string? ProjectPath { get; set; }
public bool Diagnostics { get; set; }
}
}
16 changes: 13 additions & 3 deletions src/AWS.Deploy.CLI/Commands/DeployCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -603,10 +603,12 @@ private string AskForNewCloudApplicationName(DeploymentTypes deploymentType, Lis
allowEmpty: false,
defaultAskValuePrompt: inputPrompt);

if (!string.IsNullOrEmpty(cloudApplicationName) && _cloudApplicationNameGenerator.IsValidName(cloudApplicationName))
if (string.IsNullOrEmpty(cloudApplicationName) || !_cloudApplicationNameGenerator.IsValidName(cloudApplicationName))
PrintInvalidApplicationNameMessage();
else if (deployedApplications.Any(x => x.Name.Equals(cloudApplicationName)))
PrintApplicationNameAlreadyExistsMessage();
else
return cloudApplicationName;

PrintInvalidApplicationNameMessage();
}
}

Expand Down Expand Up @@ -652,6 +654,14 @@ private void PrintInvalidApplicationNameMessage()
"It must start with an alphabetic character and can't be longer than 128 characters");
}

private void PrintApplicationNameAlreadyExistsMessage()
{
_toolInteractiveService.WriteLine();
_toolInteractiveService.WriteErrorLine(
"Invalid application name. There already exists a CloudFormation stack with the name you provided. " +
"Please choose another application name.");
}

private bool ConfirmDeployment(Recommendation recommendation)
{
var message = recommendation.Recipe.DeploymentConfirmation?.DefaultMessage;
Expand Down
25 changes: 19 additions & 6 deletions src/AWS.Deploy.CLI/ConsoleUtilities.cs
Original file line number Diff line number Diff line change
Expand Up @@ -268,14 +268,27 @@ public UserResponse<T> AskUserToChooseOrCreateNew<T>(IEnumerable<T> options, str
defaultValue = userInputConfiguration.CreateNew || !options.Any() ? createNewLabel : userInputConfiguration.DisplaySelector(options.First());
}

if (optionStrings.Any())
var displayOptionStrings = new List<string>();

// add empty option at the top if configured
if (userInputConfiguration.EmptyOption)
{
var displayOptionStrings = new List<string>(optionStrings);
if (userInputConfiguration.EmptyOption)
displayOptionStrings.Insert(0, Constants.CLI.EMPTY_LABEL);
if (userInputConfiguration.CreateNew)
displayOptionStrings.Add(createNewLabel);
displayOptionStrings.Add(Constants.CLI.EMPTY_LABEL);
}

// add all the options, this can be empty list if there are no options
// e.g. selecting a role for a service when there are no roles with a service principal
displayOptionStrings.AddRange(optionStrings);

// add create new option at the bottom if configured
if (userInputConfiguration.CreateNew)
{
displayOptionStrings.Add(createNewLabel);
}

// if list contains any options, ask user to choose one
if (displayOptionStrings.Any())
{
var selectedString = AskUserToChoose(displayOptionStrings, title, defaultValue, defaultChoosePrompt);

if (selectedString == Constants.CLI.EMPTY_LABEL)
Expand Down
8 changes: 8 additions & 0 deletions src/AWS.Deploy.CLI/Exceptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,4 +76,12 @@ public class FailedToFindDeploymentProjectRecipeIdException : DeployToolExceptio
{
public FailedToFindDeploymentProjectRecipeIdException(DeployToolErrorCode errorCode, string message, Exception? innerException = null) : base(errorCode, message, innerException) { }
}

/// <summary>
/// Throw if failed to retrieve credentials from the specified profile name.
/// </summary>
public class FailedToGetCredentialsForProfile : DeployToolException
{
public FailedToGetCredentialsForProfile(DeployToolErrorCode errorCode, string message, Exception? innerException = null) : base(errorCode, message, innerException) { }
}
}
Loading

0 comments on commit b60c3d5

Please sign in to comment.