-
Notifications
You must be signed in to change notification settings - Fork 0
/
cloudskills.html
220 lines (194 loc) · 18.8 KB
/
cloudskills.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
/* CloudSkills Bootcamp Projects */
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Adam on AWS | CloudSkills Bootcamp Projects</title>
<link rel="stylesheet" type="text/css" href="css/styles.css" />
</head>
<body>
<div class="page-container">
<div id="title-bar">adam <span class="yellow-text">snetiker</span><br><span class="small-teal-text">Solutions Architect Portfolio</span></div>
<img id="header-image" src="images/website-header.png">
<div class="content-container">
<h1>CloudSkills Projects</h1><br>
<h2>CloudNative DevOps Bootcamp</h2>
<br>
<h3>Week 1: DevOps Fundamental Skills</h3>
<p class="service">Project 1: Getting Started with GitHub</p>
<p>Since I've been working on this project for a while, I've already set up a <a href="https://github.com/adam-snetiker" target="_blank">GitHub account</a> and a repository called <a href="https://github.com/adam-snetiker/AdamOnAWS" target="_blank">AdamOnAWS</a>. This activity serves as a great introduction to version control, and it's nice to see contribution activity in my account.</p>
<p>
<b>Git Commands</b><br>
<code style="background-color: #EEEEEE; padding-top: 4px; padding-bottom: 4px;">
git add <em>filename</em> or * or *.extension<br>
git commit -m "Message about new commit here."<br>
git push origin <em>repository name</em>
</code>
</p>
<p class="service">Project 2: Setting up Your First Azure Environment</p>
<p>I used to work with a startup that hired developers who used Azure. I created an account and gave them permission to connect, so I already completed this step. </p>
<ul>
<li>In the portal, I started a free trial for 12 months along with receiving a $200 credit to use on services that aren't free. To do this, I had to verify my phone number and add a credit card, just like I did with AWS.</li></ul>
<p class="service">Project 3: Setting up Your First AWS Environment</p>
<p>Since I've been using AWS for a couple of months already, I have a fully-functional account. Even though I'm only building a project for myself, I actually created two accounts:</p>
<ul>
<li>A <strong class="yellow-text">root account</strong>, on which I enabled MFA.</li>
<li>An <strong class="yellow-text">IAM account</strong>, used to administer all services following best practices.</li></ul>
<p class="service">Project 4: Setting up Projects in GitHub</p>
<p>Under the <strong class="yellow-text">Projects</strong> tab in GitHub, I created a new project using the <em>Basic Kanban</em> template to track the status of tasks. This board includes three columns:</p>
<ul>
<li>To do</li>
<li>In progress</li>
<li>Done</li>
</ul>
<p>Other capabilities include:</p>
<ul>
<li>Add a new column</li>
<li>Drag and drop cards between columns</li>
<li>Search for and add issues to projects or repositories</li>
<li>Automate various board tasks</li>
<li>Archive cards or full columns</li>
</ul>
<p class="service">Project 5: Setting up Your First GitHub Action</p>
<p>Earlier, I set up a workflow to sync my repo with my S3 bucket. It wasn't working successfully, but it was exposing my access keys, so I disabled it. I'm looking forward to figuring this out so I can successfully sync my files to S3 every time a new change is pushed into GitHub.</p>
<br>
<h3>Week 2: Scripting Like a Developer</h3>
<p class="service">Project 1: Setting up a Dev Environment from Start to Finish</p>
<ul>
<li>Installed Visual Studio Code</li>
<li>Installed Python and PowerShell extensions. Had to download .vsix files and install these into VS Code manually.</li>
<li>Signed up for <strong class="yellow-text">GitHub Codespaces</strong> beta waitlist</li>
</ul>
<p class="service">Project 2: Reusable and Clean Python Code</p>
<p>In this project, I used Python to create an S3 bucket with the <strong class="yellow-text">Boto3</strong> library, which is used to access AWS resources. First, I attempted to install boto3 using the command <code style="background-color: #EEEEEE; padding: 4px;">pip install boto3</code> in the terminal tab of VS Code. When running my code, I got an error message saying the module didn't exist, so I had to research a different way to solve the problem.
<br><br>
I found an alternative and set up the <strong class="yellow-text">AWS SDK</strong> for Python using the following commands:<br><br>
<code style="background-color: #EEEEEE; padding-top: 4px; padding-bottom: 4px;">
$ pip install virtualenv<br>
$ cd boto3<br>
$ virtualenv venv<br>
...<br>
$ . venv/bin/activate<br>
$ python -m pip install -r requirements.txt<br>
$ python -m pip install -e .
</code>
<br><br>
This solved the first problem, but when I ran the code again I got an error saying the unspecified location constraint is not compatible with the endpoint to which the command was sent. After researching <em>this</em> problem, I solved it by adding the following to my code:
<br><br>
<code style="background-color: #EEEEEE; padding: 4px;">
CreateBucketConfiguration = {<br>
'LocationConstraint': 'us-west-1'<br>
},</code>
<br><br>
After solving this problem as well, I was met with an access denied error. To fix this, I went back to the console and signed in under my root account. I then granted the <strong class="yellow-text">S3FullAccess</strong> policy to the IAM account I'm using to connect to AWS from my local machine.
<br><br>
A quick look at the S3 bucket list confirms successful creation of a new bucket called <em>snetcloudnative</em>. I can now reuse this code any time I want to create a new s3 bucket by running the command <br>
<code style="background-color: #EEEEEE; padding: 4px;">python3 ./s3bucket.py <em>bucketname</em></code>
<p class="service">Project 3: Reusable and Clean PowerShell Code</p>
<p>For this project, the task is to write a PowerShell script that creates a new <strong class="yellow-text">Azure resource group</strong>. Since I'm starting from scratch, I need to install both PowerShell and the Azure CLI.
<br><br>
In order to run Homebrew, I first had to convert the shallow clone to a full clone using the following commands:<br><br> <code style="background-color: #EEEEEE; padding: 4px;">git -C /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core fetch --unshallow</code><br> <code style="background-color: #EEEEEE; padding: 4px;">git -C /usr/local/Homebrew/Library/Taps/homebrew/homebrew-cask fetch --unshallow</code>
<br><br>
Before I install the Azure CLI, it appears I have to install Xcode Developer tools using the command <code style="background-color: #EEEEEE; padding: 4px;">xcode-select --install</code>. After that, and once I have a full clone of Homebrew, I'm able to
I'm able to successfully install the <strong class="yellow-text">Azure CLI</strong> using <code style="background-color: #EEEEEE; padding: 4px;">brew update && brew install azure-cli</code>.
<br><br>To begin, I installed PowerShell using the command <code style="background-color: #EEEEEE; padding: 4px;">brew install --cask powershell</code> and verified that it's working with <code style="background-color: #EEEEEE; padding: 4px;">pwsh</code>.
This is also used to start the shell, which is necessary because otherwise I'd be running commands in Bash. In VS Code, it appears the default shell is zsh.
<br><br>
When running my code, I ran into an error that said the module was not part of a cmdlet, script or file. Basically, PowerShell couldn't find the specific Azure CLI command I want to use, which is <code style="background-color: #EEEEEE; padding: 4px;">New-AzResourceGroup</code>. To troubleshoot the problem, here are the steps I took:
<ul>
<li>Looked up how to install a PowerShell module</li>
<li>Found the name of the correct module that contains the New-AzResourceGroup command</li>
<li>Ran a search for the module and installed it once it was found. The correct module for this project is <strong class="yellow-text">Az.Resources</strong>. The command I used to find and install the module is <code style="background-color: #EEEEEE; padding: 4px;">Find-Module -Name Az.Resources | Install-Module</code>.</li>
<li>Added <code style="background-color: #EEEEEE; padding: 4px;">Import-Module Az.Resources</code> to the top of my code to import the module.</li>
</ul>
<p>In order to successfully run the code, I had to run <code style="background-color: #EEEEEE; padding: 4px;">Connect-AzAccount</code>, which opened a browser tab so I could log in to Azure. Finally, after the connection was established, I ran <code style="background-color: #EEEEEE; padding: 4px;">New-ResourceGroup -rgName snetRG01 -location westus</code> to create a resource group called snetRG01 in the West US region.
<br><br>Last but not least, I was able to confirm successful creation of the resource group in the Azure console.</p>
<p class="service">Project 4: Linting in PowerShell and Python</p>
<p>This project is all about <strong class="yellow-text">linting</strong>, which means optimizing and cleaning up code so it follows best practices.
<br><br>
In Python, we start with <code style="background-color: #EEEEEE; padding: 4px;">pip install pylint</code> to install the linter. To begin cleaning up code, I ran <code style="background-color: #EEEEEE; padding: 4px;">pylint ./s3bucket.py</code> in the directory where my code is, and got my first round of results.
<br><br>
Each time pylint is run, it provides your code with a rating. My initial rating was <strong>3.08</strong>/10, but after making corrections I ended up wit ha rating of <strong>9.00</strong>/10. Some of the changes I made are:
<ul>
<li>Added an empty line at the bottom of the code</li>
<li>Placed <code style="background-color: #EEEEEE; padding: 4px;">import sys</code> <em>before</em> <code style="background-color: #EEEEEE; padding: 4px;">import boto3</code></li>
<li>Added document strings to both the module and functions to describe what they do. For example, my module docstring is <code style="background-color: #EEEEEE; padding: 4px;">"""This script creates an S3 bucket using the Boto3 library"""</code>.</li>
<li>Removed the <code style="background-color: #EEEEEE; padding: 4px;">bucket</code> variable from the <code style="background-color: #EEEEEE; padding: 4px;">s3_bucket.create_bucket</code> function because it was never used.</li>
</ul>
<br>
For PowerShell, I created a file called <em>linting.ps1</em> that will be run against my code in <em>New-ResourceGroup.ps1</em>. I then took the following steps:
<ul>
<li>In the PowerShell Integrated Console, I ran <code style="background-color: #EEEEEE; padding: 4px;">Install-Module -Name PSScriptAnalyzer -RequiredVersion 1.18.3</code> to install it.</li>
<li>Imported the script analyzer module into the code using <code style="background-color: #EEEEEE; padding: 4px;">Import-Module PSScriptAnalyzer</code>. I'm on a Mac, but was told that it's automatically included in Windows 10.</li>
<li>The entire linting script consists of one line of code: Imported it into the code using <code style="background-color: #EEEEEE; padding: 4px;">Invoke-ScriptAnalyizer -Path .</code>. This will analyze all scripts in the current directory.</li>
</ul>
<p class="service">Project 5: Testing in PowerShell and Python</p>
<p>While linting is one form of testing the cleanliness of code, unit testing is another form to make sure it works as expected. In this project, we ran unit tests on the Python script to create a new S3 bucket and the PowerShell script that creates a new resource group.</p>
Starting with PowerShell, the steps I took are as follows:
<ul>
<li>Created a new PowerShell script file called <em>New-ResourceGroup_test.ps1</em></li>
<li>Installed Pester, a popular framework for various types of application testing, by running <code style="background-color: #EEEEEE; padding: 4px;">Install-Module -Name Pester -RequiredVersion 4.7.3</code></li>
<li>Run the test by using <code style="background-color: #EEEEEE; padding: 4px;">Invoke-Pester .\New-ResourceGroup_test.ps1</code> or by selecting the entire test function and selecting 'Run Selection' from the menu.
<li>Fixed code after observing failed test.</li>
</ul>
<p>The python tests go a little deeper and test the bucket name and region to make sure they both match the expected values and they're strings. To do this, I did the following:</p>
<ul>
<li>Import the python unittest package</li>
<li>Select code and choose 'Run Python File in Terminal' from the menu to perform the test</li>
<li>Observe results, which state that 4 tests were run and the status is OK.</li>
</ul>
<p class="service">Project 6: Documenting Code</p>
Documenting code is important for develoeprs to do so others can understand it. When using GitHub especially, the README file gives visitors an idea of what's in the repository, how to contribute, and provides other information. It's written in markdown format, which consists of several different things.
<strong class="yellow-test">#</strong> is used for heading, similar to H1 - H6 tags in HTML. In fact, the number of pound signs correspond to the heading level, so:
<ul>
<li># = H1</li>
<li>## = H2</li>
<li>### = H3</li>
<li>#### = H4</li>
<li>##### = H5</li>
<li>###### = H6</li>
</ul>
<p>As far as formatting goes, a <strong class="yellow-text">*</strong> on either side of a string is used for bold text and <strong class="yellow-text">_</strong> for italics.
<br><br>
GitHub has an excellent guide called <a href="https://guides.github.com/features/mastering-markdown/" target="_blank">Mastering Markdown</a> that contains the above syntax rules and more.
</p>
<br>
<h3>Week 3: Infrastructure as Code</h3>
<p class="service">Project 1: Building an ARM Template for Virtual Machine Deployment in Azure</p>
<p>ARM stands for <strong class="yellow-text">Azure Resource Manager</strong>. Templates are used to create resources via code instead of manually clicking in the Azure interface.
This is the process I followed to build my first one:
<ul>
<li>Install the extension called <em>Azure Resource Manager (ARM) Tools</em> in Visual Studio Code.
This extension allows you to create template snippets on the fly that will be deployed via the Azure CLI.</li>
<li>Created a new file called <em>template.json</em>. Thanks to the extension, VS code automatically recognizes it as a JSON file. To start, we begin typing 'arm' and select the first item, 'arm!' from the menu to create a generic template, which contains the following sections:
<ul>
<li>$schema</li>
<li>parameters</li>
<li>functions</li>
<li>variables</li>
<li>resources</li>
<li>outputs</li>
</ul></li>
<li>In the resources section, I began typing 'arm' again and selected 'arm-vm-ubuntu' from the list to automatically generate an Ubuntu Linux virtual machine. I then changed the default name, <em>ubuntuVM1</em>, to <em>ajsnetVM1</em> to make it globally unique.</li>
<li>In the parameters section, typing 'arm' brings up an option to create a new-parameter, which generates a snippet containing a type and metadata such as a description. I named the paramter 'adminPassword' and set the descripton to 'Administrator Password'. Further down in the resources section under osProfile, I then set adminPassword to <code style="background-color: #EEEEEE; padding: 4px;">"[parameters('adminPassword')]"</code>. The list of parameters is available thanks to the ARM extension for VS code. </li>
<li>In the output section, I want to output the public IP and Fully Qualified Domain Name of the new virtual machine using <code style="background-color: #EEEEEE; padding: 4px;">"[reference(resourceId('Microsoft.Network/publicIPAddresses', 'ajsnetVM1-PublicIP')).dnsSettings.fqdn]"</code></li>
<li>Once complete, I entered a powershell terminal and logged into Azure using <code style="background-color: #EEEEEE; padding: 4px;">az login</code>.</li>
<p>
<strong>Note:</strong> If you have trouble logging in, you may have to specify your tenant ID, which can be found by searching 'tenant properties' in the Azure portal. Copy the Tenant ID, then run <code style="background-color: #EEEEEE; padding: 4px;">az login --tenant <em>tenantID</em></code>.</p>
<li>Once logged in, I ran <code style="background-color: #EEEEEE; padding: 4px;">az deployment group create --resource-group snetRG01 --template-file ./template.json -p adminPassword="********"</code></li>
<li>Finally, I can verify successful creation of the VM by visiting the Virtual machines service in my Azure console. The VM, along with all of the other resources that were provisioned, are listed in the <em>snetRG01</em>resource group.</li>
</ul>
</p>
<p class="service">Project 2: Building a Terraform Module to Create a Virtual Network in AWS</p>
<p class="service">Project 3: Testing Infrastructure-as-Code</p>
<p class="service">Project 4: Intro to Azure Bicep</p>
<br>
<h3>Week 4: GitHub and Source Control</h3>
<p class="service">Project 1: VS Code with Git and GitHub</p>
<p class="service">Project 2: Working Through Push Conflicts</p>
<p class="service">Project 3: Contributing to an Open Source Project</p>
<p><strong>Note: </strong> Script files and test result screenshots for all projects can be found in my <a href="https://github.com/adam-snetiker/cloudskills" target="_blank">cloudskills</a> repository.</p>
</div>
</div>
</body>
</html>