diff --git a/src/AWS.Deploy.Constants/CDK.cs b/src/AWS.Deploy.Constants/CDK.cs
index 2d8fe7c4d..a2c5c1563 100644
--- a/src/AWS.Deploy.Constants/CDK.cs
+++ b/src/AWS.Deploy.Constants/CDK.cs
@@ -11,7 +11,15 @@ internal static class CDK
///
/// Deployment tool workspace directory to create CDK app during the deployment.
///
- public static readonly string DeployToolWorkspaceDirectoryRoot = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), ".aws-dotnet-deploy");
+ public static string DeployToolWorkspaceDirectoryRoot {
+ get
+ {
+ var deployToolWorkspace = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), ".aws-dotnet-deploy");
+ if (!Directory.Exists(deployToolWorkspace))
+ Directory.CreateDirectory(deployToolWorkspace);
+ return deployToolWorkspace;
+ }
+ }
///
/// Directory that contains CDK projects
diff --git a/src/AWS.Deploy.Orchestration/CDK/CDKManager.cs b/src/AWS.Deploy.Orchestration/CDK/CDKManager.cs
index d2ae5d15c..8946acb15 100644
--- a/src/AWS.Deploy.Orchestration/CDK/CDKManager.cs
+++ b/src/AWS.Deploy.Orchestration/CDK/CDKManager.cs
@@ -45,17 +45,22 @@ public CDKManager(ICDKInstaller cdkInstaller, INPMPackageInitializer npmPackageI
_interactiveService = interactiveService;
}
+ private async Task CreateCDKBootstrapTemplate()
+ {
+ // The CDK bootstrap template can be generated by running 'cdk bootstrap --show-template'.
+ // We need to keep the template up to date while making sure that the 'Staging Bucket' retention policies are set to 'Delete'.
+ var cdkBootstrapTemplate = typeof(CdkProjectHandler).Assembly.ReadEmbeddedFile(TemplateIdentifier);
+ await using var cdkBootstrapTemplateFile = new StreamWriter(Constants.CDK.CDKBootstrapTemplatePath);
+ await cdkBootstrapTemplateFile.WriteAsync(cdkBootstrapTemplate);
+ }
+
public async Task EnsureCompatibleCDKExists(string workingDirectory, Version cdkVersion)
{
await s_cdkManagerSemaphoreSlim.WaitAsync();
try
{
- // The CDK bootstrap template can be generated by running 'cdk bootstrap --show-template'.
- // We need to keep the template up to date while making sure that the 'Staging Bucket' retention policies are set to 'Delete'.
- var cdkBootstrapTemplate = typeof(CdkProjectHandler).Assembly.ReadEmbeddedFile(TemplateIdentifier);
- await using var cdkBootstrapTemplateFile = new StreamWriter(Constants.CDK.CDKBootstrapTemplatePath);
- await cdkBootstrapTemplateFile.WriteAsync(cdkBootstrapTemplate);
+ await CreateCDKBootstrapTemplate();
var installedCdkVersion = await _cdkInstaller.GetVersion(workingDirectory);
if (installedCdkVersion.Success && installedCdkVersion.Result?.CompareTo(cdkVersion) >= 0)