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 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:
{
"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:
{
"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
- Create a new
JSON
file. - 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.
- 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.
- Add a Settings object to define deployment settings.
- To set the
ECS Service Name
, get the ID from the Recipe which isECSServiceName
. The value needs to be the same type as theType
of setting.ECS Service Name
has a typeString
, so give it a valueWebApp1-service
. - To set
ECS Cluster
, the ID isECSCluster
and the setting has a typeObject
. The value ofObject
types is another JSON blob representing the setting ID and value of theObject's children settings
. To set the 2 children settingsCreate New ECS Cluster
andNew Cluster Name
, use the IDsCreateNew
andNewClusterName
respectively.Create New ECS Cluster
has a typeBool
so we can settrue
orfalse
, andNew Cluster Name
is aString
. The deployment settings file will look like this:
{
"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.