<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: Saad Mahmud</title>
    <description>The latest articles on Forem by Saad Mahmud (@saad135).</description>
    <link>https://forem.com/saad135</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F826684%2F02e70d78-b529-4508-8fc8-2b3688cf9c2a.png</url>
      <title>Forem: Saad Mahmud</title>
      <link>https://forem.com/saad135</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/saad135"/>
    <language>en</language>
    <item>
      <title>Script to init aws cdk in a non empty directory</title>
      <dc:creator>Saad Mahmud</dc:creator>
      <pubDate>Sat, 10 Dec 2022 08:58:44 +0000</pubDate>
      <link>https://forem.com/saad135/script-to-init-aws-cdk-in-a-non-empty-directory-2fon</link>
      <guid>https://forem.com/saad135/script-to-init-aws-cdk-in-a-non-empty-directory-2fon</guid>
      <description>&lt;p&gt;Recently I tried to run the &lt;code&gt;cdk init&lt;/code&gt; command using the aws cdk command line interface, and I came to realize that aws cdk does not allow one to initialize a cdk app in a non-empty directory. Upon conducting a quick google search, I came across this &lt;a href="https://stackoverflow.com/questions/63348336/aws-cdk-init-for-an-existing-project" rel="noopener noreferrer"&gt;stackoverflow post&lt;/a&gt; where I learned that the solution is to initialize in an empty directory and manually merge that directory with the project directory.&lt;/p&gt;

&lt;p&gt;Hence, I decided to run this simple powershell script that tries to automate this process. I hope you find this useful and please do let me know your thoughts on this :-). The code for the powershell script is shown below:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$project_location = Get-Location
$temp_app_dir_name = 'infra'
$temp_app_location = Join-Path -Path $project_location -ChildPath $temp_app_dir_name
# Write-Output -InputObject $project_location\requirements.txt

mkdir $temp_app_location

Set-Location -Path $temp_app_location
cdk init app --language python
Set-Location -Path $project_location

# Rename folder so its easier to move out content later
$temp_app_dir_renamed = 'infra_temp'
$temp_app_location_renamed = Join-Path -Path $project_location -ChildPath $temp_app_dir_renamed
Rename-Item -Path $temp_app_location -NewName $temp_app_location_renamed

Get-Content -Path $temp_app_location_renamed\requirements.txt &amp;gt;&amp;gt; $project_location\requirements.txt
Get-Content -Path $temp_app_location_renamed\.gitignore &amp;gt;&amp;gt; $project_location\.gitignore

Remove-Item -Path $temp_app_location_renamed\requirements.txt
Remove-Item -Path $temp_app_location_renamed\.gitignore
Remove-Item -Path $temp_app_location_renamed\README.md
Remove-Item -Path $temp_app_location_renamed\.venv -Recurse

Move-Item -Path $temp_app_location_renamed\* -Destination $project_location

Remove-Item -Path $temp_app_location_renamed

cdk synth
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>discuss</category>
      <category>technology</category>
    </item>
  </channel>
</rss>
