Skip to content

Commit

Permalink
feat: add new documentation generator to generate deployment settings…
Browse files Browse the repository at this point in the history
… file documentation
  • Loading branch information
philasmar committed Jan 13, 2023
1 parent 964eb71 commit 5fc865b
Show file tree
Hide file tree
Showing 40 changed files with 2,222 additions and 82 deletions.
52 changes: 52 additions & 0 deletions .github/workflows/DetectDocGeneratorChanges.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: Detect Doc Generator Changes

on: [pull_request]

permissions:
id-token: write

jobs:
build:

runs-on: ubuntu-latest

steps:
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v1
with:
role-to-assume: ${{ secrets.CI_AWS_ROLE_ARN }}
role-duration-seconds: 7200
aws-region: us-west-2
- uses: actions/checkout@v2
with:
fetch-depth: '0'
- name: Setup .NET Core 6.0
uses: actions/setup-dotnet@v1
with:
dotnet-version: 6.0.x
- name: Restore dependencies
run: dotnet restore
- name: Build
run: dotnet build --no-restore
- name: Run Client Generator
run: |
cd ./src/AWS.Deploy.DocGenerator
dotnet run --project ./AWS.Deploy.DocGenerator.csproj
- name: Check For Git Untracked Changes
id: gitcheck
shell: pwsh
run: |
$newFiles=$(git ls-files --others --exclude-standard | wc -l)
$modifiedFiles=$(git diff --name-only | wc -l)
"newFiles=$newFiles" >> $env:GITHUB_OUTPUT
"modifiedFiles=$modifiedFiles" >> $env:GITHUB_OUTPUT
- name: Fail If New Files Detected
if: steps.gitcheck.outputs.newFiles != 0
run: |
echo "New files have been generated after running 'AWS.Deploy.DocGenerator'. Make sure to add the new files to your working branch."
exit 1
- name: Fail If Modified Files Detected
if: steps.gitcheck.outputs.modifiedFiles != 0
run: |
echo "Updated files have been generated after running 'AWS.Deploy.DocGenerator'. Make sure to commit the updated files to your working branch."
exit 1
32 changes: 32 additions & 0 deletions .github/workflows/doc-builder.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,46 @@ on:

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

permissions:
id-token: write
contents: write

jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v1
with:
role-to-assume: ${{ secrets.CI_AWS_ROLE_ARN }}
aws-region: us-west-2
- uses: actions/checkout@v2
with:
fetch-depth: '0'
- uses: actions/setup-python@v2
with:
python-version: 3.x
- name: Setup .NET Core 6.0
uses: actions/setup-dotnet@v1
with:
dotnet-version: 6.0.x
- run: pip install mkdocs-material==8.2.9
- run: pip install mkdocs-awesome-pages-plugin==2.8.0
- name: Restore dependencies
run: dotnet restore
- name: Build
run: dotnet build --no-restore
- name: Run Client Generator
run: |
cd ./src/AWS.Deploy.DocGenerator
dotnet run --project ./AWS.Deploy.DocGenerator.csproj
- name: Commit and Push next version
id: commit-push
run: |
git config --global user.email "[email protected]"
git config --global user.name "aws-sdk-dotnet-automation"
git add site/
git commit -m "Update documentation generated by AWS.Deploy.DocGenerator"
git push
- run: mkdocs gh-deploy --force
16 changes: 15 additions & 1 deletion AWS.Deploy.sln
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Microsoft Visual Studio Solution File, Format Version 12.00
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.0.32126.317
MinimumVisualStudioVersion = 10.0.40219.1
Expand Down Expand Up @@ -68,6 +68,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WebApiNET6", "testapps\WebA
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BlazorWasm60", "testapps\BlazorWasm60\BlazorWasm60.csproj", "{CEEBEC39-40E5-4A9B-878A-6EDB52B9B43E}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AWS.Deploy.DocGenerator", "src\AWS.Deploy.DocGenerator\AWS.Deploy.DocGenerator.csproj", "{6D4BD0C2-C2A0-4AFB-BC22-623DD64A4F84}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AWS.Deploy.DocGenerator.UnitTests", "test\AWS.Deploy.DocGenerator.UnitTests\AWS.Deploy.DocGenerator.UnitTests.csproj", "{7E661545-7DFD-4FE3-A5F9-767FAE30DFFE}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -166,6 +170,14 @@ Global
{CEEBEC39-40E5-4A9B-878A-6EDB52B9B43E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{CEEBEC39-40E5-4A9B-878A-6EDB52B9B43E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{CEEBEC39-40E5-4A9B-878A-6EDB52B9B43E}.Release|Any CPU.Build.0 = Release|Any CPU
{6D4BD0C2-C2A0-4AFB-BC22-623DD64A4F84}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{6D4BD0C2-C2A0-4AFB-BC22-623DD64A4F84}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6D4BD0C2-C2A0-4AFB-BC22-623DD64A4F84}.Release|Any CPU.ActiveCfg = Release|Any CPU
{6D4BD0C2-C2A0-4AFB-BC22-623DD64A4F84}.Release|Any CPU.Build.0 = Release|Any CPU
{7E661545-7DFD-4FE3-A5F9-767FAE30DFFE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{7E661545-7DFD-4FE3-A5F9-767FAE30DFFE}.Debug|Any CPU.Build.0 = Debug|Any CPU
{7E661545-7DFD-4FE3-A5F9-767FAE30DFFE}.Release|Any CPU.ActiveCfg = Release|Any CPU
{7E661545-7DFD-4FE3-A5F9-767FAE30DFFE}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down Expand Up @@ -196,6 +208,8 @@ Global
{7C330493-9BF7-4DB6-815B-807C08500AC6} = {C3A0C716-BDEA-4393-B223-AF8F8531522A}
{B2EA65BD-9FFE-4452-B2DC-574EB1A9FAF1} = {C3A0C716-BDEA-4393-B223-AF8F8531522A}
{CEEBEC39-40E5-4A9B-878A-6EDB52B9B43E} = {C3A0C716-BDEA-4393-B223-AF8F8531522A}
{6D4BD0C2-C2A0-4AFB-BC22-623DD64A4F84} = {11C7056E-93C1-408B-BD87-5270595BBE0E}
{7E661545-7DFD-4FE3-A5F9-767FAE30DFFE} = {BD466B5C-D8B0-4069-98A9-6DC8F01FA757}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {5A4B2863-1763-4496-B122-651A38A4F5D7}
Expand Down
10 changes: 9 additions & 1 deletion mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,11 @@ nav:
- Overview: docs/deployment-projects/index.md
- Recipe File: docs/deployment-projects/recipe-file.md
- CDK Project: docs/deployment-projects/cdk-project.md
- Integrating with CI/CD: docs/cicd.md
- Integrating with CI/CD:
- Overview: docs/cicd/cicd.md
- Deployment Settings File: docs/cicd/deployment-settings-file.md
- Deployment Recipes:
- ... | flat
- Tutorials:
- Customizing deployment projects: tutorials/custom-project.md
- Troubleshooting Guide:
Expand All @@ -58,3 +62,7 @@ theme:
markdown_extensions:
- pymdownx.emoji:
emoji_index: !!python/name:materialx.emoji.twemoji

plugins:
- search
- awesome-pages
8 changes: 5 additions & 3 deletions site/content/docs/cicd.md → site/content/docs/cicd/cicd.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Integrating with CI/CD

You can use AWS Deploy Tool when developing your app using any Continuous Deployment system. Continuous Deployment systems let you automatically build, test and deploy your application each time you check in updates to your source code. Before you can use AWS Deploy Tool in your CD pipeline, you must have [required pre-requisites](../docs/getting-started/pre-requisites.md) installed and configured in the CD environment.
You can use AWS Deploy Tool when developing your app using any Continuous Deployment system. Continuous Deployment systems let you automatically build, test and deploy your application each time you check in updates to your source code. Before you can use AWS Deploy Tool in your CD pipeline, you must have [required pre-requisites](../../docs/getting-started/pre-requisites.md) installed and configured in the CD environment.

### Suppressing prompts with `--silent`

Expand Down Expand Up @@ -49,10 +49,10 @@ This will create a JSON file at `MyWebApplication/MyWebApplication/deploymentset

```json
{
"AWSProfile": <AWS_PROFILE>
"AWSProfile": <AWS_PROFILE>,
"AWSRegion": <AWS_REGION>,
"ApplicationName": <APPLICATION_NAME>,
"RecipeId": <RECIPE_ID>
"RecipeId": <RECIPE_ID>,
"Settings": <JSON_BLOB>
}
```
Expand All @@ -67,6 +67,8 @@ This will create a JSON file at `MyWebApplication/MyWebApplication/deploymentset

* _**Settings**_: This is a JSON blob that stores the values of all available settings that can be tweaked to adjust the deployment configuration.

For more info on how to create your own `Deployment settings file`, go to [Creating a deployment settings file](deployment-settings-file.md)

### Invoking from CI/CD

The `--apply` switch on the deploy command allows you to specify a deployment settings file.
Expand Down
93 changes: 93 additions & 0 deletions site/content/docs/cicd/deployment-settings-file.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
# Creating a deployment settings file

### What is a deployment settings file

A deployment settings file allows you to define the deployment settings of your application in a _JSON_ format. This JSON file can be version controlled and plugged into your CI/CD system for future deployments.

Deployment settings files could be used as a way to automate your deployments or use them in a [CI/CD setting](./cicd.md) where you would define all the settings that you need to apply for your deployment and then use the `--apply` flag on the CLI to link to the deployment setting file.

By doing this, the AWS .NET deployment tool reads all the settings you have defined and applies them to the deployment. You will need to do a final confirmation to initiate the deployment in the CLI. However, you can bypass the confirmation by making the deployment a silent one. This can be done by adding the `--silent` flag which will turn off any prompts.

The deployment settings file has the following structure:

```json
{
"AWSProfile": <AWS_PROFILE>,
"AWSRegion": <AWS_REGION>,
"ApplicationName": <APPLICATION_NAME>,
"RecipeId": <RECIPE_ID>,
"Settings": <JSON_BLOB>
}
```

* _**AWSProfile**_: The name of the AWS profile that will be used during deployment.

* _**AWSRegion**_: The name of the AWS region where the deployed application is hosted.

* _**ApplicationName**_: The name that is used to identify your cloud application within AWS. If the application is deployed via AWS CDK, then this name points to the CloudFormation stack.

* _**RecipeId**_: The recipe identifier that will be used to deploy your application to AWS.

* _**Settings**_: This is a JSON blob that stores the values of all available settings that can be tweaked to adjust the deployment configuration. This is represented as a _JSON_ object that contains the deployment setting IDs and values as a key/pair configuration.

*Note:* _**AWSProfile, AWSRegion and ApplicationName**_ are optional and can be overriden by using the appropriate command line switches. This enables users to craft a *deployment settings file* that could be used for multiple AWS profiles and regions.

An example of overriding _**AWSProfile, AWSRegion and ApplicationName**_ in the CLI:
```
dotnet aws deploy --application-name WebApp1 --profile default --region us-west-2
```

Each recipe has its own set of settings that can be configured. The following pages in this section list the settings for each recipe that can be used to fill in the `Settings` section of the file.

### Example of a deployment settings file

An example of what a deployment settings file would look like:
```json
{
"AWSProfile": "default",
"AWSRegion": "us-west-2",
"ApplicationName": "WebApp1",
"RecipeId": "AspNetAppEcsFargate",
"Settings": {
"ECSCluster": {
"CreateNew": true,
"NewClusterName": "WebApp1-Cluster"
},
"ECSServiceName": "WebApp1-service",
"DesiredCount": 3,
"ApplicationIAMRole": {
"CreateNew": true
}
}
}
```
Settings that contain child settings under them are represented as another _JSON_ object similar to the example provided above.

### How to create a deployment settings file

1. Create a new `JSON` file.
2. Add the 3 properties _**AWSProfile, AWSRegion and ApplicationName**_. These are generic and not tied to a specific *Recipe* file.
> _**AWSProfile**_: The name of the AWS profile that will be used during deployment.
> _**AWSRegion**_: The name of the AWS region where the deployed application is hosted.
> _**ApplicationName**_: The name that is used to identify your cloud application within AWS. If the application is deployed via AWS CDK, then this name points to the CloudFormation stack.
3. Pick a *Recipe* from the **Deployment Recipes** section in the navigation to use for your deployment. A Recipe defines the .NET application type and the AWS compute to deploy it to. For example [ASP.NET Core App to Amazon ECS using AWS Fargate](./recipes/ASP.NET%20Core%20App%20to%20Amazon%20ECS%20using%20AWS%20Fargate.md).
4. Add a _**Settings**_ object to define deployment settings.
5. To set the `ECS Service Name`, get the ID from the *Recipe* which is `ECSServiceName`. The value needs to be the same type as the `Type` of setting. `ECS Service Name` has a type `String`, so give it a value `WebApp1-service`.
6. To set `ECS Cluster`, the ID is `ECSCluster` and the setting has a type `Object`. The value of `Object` types is another JSON blob representing the setting ID and value of the `Object's children settings`. To set the 2 children settings `Create New ECS Cluster` and `New Cluster Name`, use the IDs `CreateNew` and `NewClusterName` respectively. `Create New ECS Cluster` has a type `Bool` so we can set `true` or `false`, and `New Cluster Name` is a `String`. The deployment settings file will look like this:
```json
{
"AWSProfile": "default",
"AWSRegion": "us-west-2",
"ApplicationName": "WebApp1",
"RecipeId": "AspNetAppEcsFargate",
"Settings": {
"ECSCluster": {
"CreateNew": true,
"NewClusterName": "WebApp1-Cluster"
},
"ECSServiceName": "WebApp1-service"
}
}
```

Keep adding more settings by using the *Recipe* you selected as reference and be mindful of the type of setting you are setting.
Loading

0 comments on commit 5fc865b

Please sign in to comment.