Skip to content

Commit

Permalink
initial
Browse files Browse the repository at this point in the history
  • Loading branch information
id27182 committed Dec 16, 2024
1 parent 962ecf0 commit 650f801
Show file tree
Hide file tree
Showing 4 changed files with 194 additions and 1 deletion.
18 changes: 18 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: Test

run-name: ${{ github.actor }} - ${{ github.ref_name }}

on:
workflow_dispatch:
pull_request:

jobs:
validate-task:
runs-on: windows-latest
steps:
- uses: actions/checkout@v4

- name: 'Test estimate'
shell: pwsh
run: tests/test-estimate.ps1

44 changes: 43 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,43 @@
# aws_devops_task_2_estimate_costs
# AWS Essentials: estimate costs

One of main benefits of the cloud is it's cost effectiveness, that's why it's important to learn how to estimate cloud costs. In this task you will work with AWS pricing calculator to estimate the cost of the Grafana deployment you will be working on over the module.

## Prerequirements

Before completing any task in the module, make sure that you followed all the steps described in the **Environment Setup** topic, in particular:

1. Make sure you have an [AWS](https://aws.amazon.com/free/) account.

2. Install [aws cli](https://docs.aws.amazon.com/cli/latest/userguide/getting-started-install.html)

3. Install [powershell core](https://learn.microsoft.com/en-us/powershell/scripting/install/installing-powershell?view=powershell-7.4)

4. Install [terraform](https://developer.hashicorp.com/terraform/tutorials/aws-get-started/install-cli)

5. Log in to aws cli on your computer by running command:
```
aws configure
```
## Task requirements
Your Grafana deployment will consist of the following resources:
- EC2 virtual machine: we will go with 1 t2.micro running Linux;
- For the EC2 we wil need a VPC and 1 Public IP;
- We will also use some S3 storage (**S3 Standard storage**) for Grafana database backups. We will need around 10GB of space, we will do a nigtly upload of DB backups and we will clean up the old backups when we will run out of planned storage space;
- All resources will be deployed to 'eu-central-1' region;
- We will use on-demand pricing witout any reservations;
To complete this task, you will need to perform the following steps:
1. Use [AWS pricing calculator](https://calculator.aws/) to calculate our cloud infra costs.
2. Export results in JSON format: save it to file, called `estimate.json` in this repository.
3. Run automated test to check yourself.
```
pwsh ./tests/test-estimate.ps1
```
If any test fails - please check your estimate and try again.
4. Commit the `estimate.json`, and submit your solution for a review
| :memo: |Don't be worried about the total cost of infra: if you are using AWS free account - you will get all those resources for free |
|---------------|:--------------------------------------------------------------------------------------------------------------------------------|
67 changes: 67 additions & 0 deletions estimate.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
{
"Name": "My Estimate",
"Total Cost": {
"monthly": "13.67",
"upfront": "0.00",
"12 months": "164.04"
},
"Metadata": {
"Currency": "USD",
"Locale": "en_US",
"Created On": "12/12/2024",
"Legal Disclaimer": "AWS Pricing Calculator provides only an estimate of your AWS fees and doesn't include any taxes that might apply. Your actual fees depend on a variety of factors, including your actual usage of AWS services.",
"Share Url": "https://calculator.aws/#/estimate?id=44e30727acce6185accda025919bf6153f0366a1"
},
"Groups": {
"Services": [
{
"Service Name": "Amazon EC2 ",
"Region": "Europe (Frankfurt)",
"Status": "",
"Service Cost": {
"monthly": "9.78",
"upfront": "0.00",
"12 months": "117.38"
},
"Properties": {
"Tenancy": "Shared Instances",
"Operating system": "Linux",
"Workload": "Consistent, Number of instances: 1",
"Advance EC2 instance": "t2.micro",
"Pricing strategy": "On-Demand Utilization: 100 %Utilized/Month",
"Enable monitoring": "disabled",
"DT Inbound: Not selected": "0 TB per month",
"DT Outbound: Not selected": "0 TB per month",
"DT Intra-Region:": "0 TB per month"
}
},
{
"Service Name": "Public IPv4 Address",
"Region": "Europe (Frankfurt)",
"Status": "",
"Service Cost": {
"monthly": "3.65",
"upfront": "0.00",
"12 months": "43.80"
},
"Properties": {
"Number of In-use public IPv4 addresses": "1"
}
},
{
"Service Name": "S3 Standard",
"Region": "Europe (Frankfurt)",
"Status": "",
"Service Cost": {
"monthly": "0.24",
"upfront": "0.00",
"12 months": "2.88"
},
"Properties": {
"S3 Standard storage": "10 GB per month",
"S3 Standard Average Object Size": "16 MB"
}
}
]
}
}
66 changes: 66 additions & 0 deletions tests/test-estimate.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
$estimatePath = './estimate.json'

if (Test-Path $estimatePath) {
Write-Output "`u{2705} Checking if estimate file - OK. "
} else {
throw "`u{1F635} Unable to find estimate file. Please make sure that you saved you estimate to a file 'exsimate.json' in this repo and try again. "
}

$estimate = (Get-Content -Path $estimatePath | ConvertFrom-Json)

$ec2 = $estimate.Groups.Services | Where-Object {$_.'Service Name' -eq 'Amazon EC2 '}
if ($ec2 -and ($ec2.Count -eq 1 )) {
Write-Output "`u{2705} Checking if EC2 VM is present in the estimate - OK. "
} else {
throw "`u{1F635} Unable to find EC2 VM. Please make sure that you added a EC2 VM (and only one EC2 VM) to the estimate and try again. "
}
if ($ec2.Region -eq 'Europe (Frankfurt)') {
Write-Output "`u{2705} Checking if EC2 VM region in the estimate - OK. "
} else {
throw "`u{1F635} Unable to validate EC2 VM region. Please make sure that you added a EC2 VM to the 'Europe (Frankfurt)' ('eu-central-1') region and try again. "
}
if ($ec2.Properties.'Advance EC2 instance' -eq 't2.micro') {
Write-Output "`u{2705} Checking the EC2 VM size in the estimate - OK. "
} else {
throw "`u{1F635} Unable to validate EC2 VM size. Please make sure that you added a EC2 VM with size 't2.micro' and try again. "
}
if ($ec2.Properties.'Pricing strategy'.Contains('On-Demand Utilization')) {
Write-Output "`u{2705} Checking the EC2 VM prising strategy in the estimate - OK. "
} else {
throw "`u{1F635} Unable to validate EC2 VM pricing strategy. Please make sure that you chose on-demand pricing and try again. "
}
if ($ec2.Properties.'Operating system' -eq 'Linux') {
Write-Output "`u{2705} Checking the EC2 VM operating system in the estimate - OK. "
} else {
throw "`u{1F635} Unable to validate EC2 VM operating system. Please make sure that you added a EC2 VM with Linux operating system and try again. "
}
if ($ec2.Properties.'Operating system' -eq 'Linux') {
Write-Output "`u{2705} Checking the EC2 VM operating system in the estimate - OK. "
} else {
throw "`u{1F635} Unable to validate EC2 VM operating system. Please make sure that you added a EC2 VM with Linux operating system and try again. "
}


$ipV4 = $estimate.Groups.Services | Where-Object {$_.'Service Name' -eq 'Public IPv4 Address'}
if ($ipV4 -and ($ipV4.Count -eq 1 )) {
Write-Output "`u{2705} Checking if public IP resource is present in the estimate - OK. "
} else {
throw "`u{1F635} Unable to find Public IP resource in the estimate. Please make sure that you added a VPC with Public IP selected to the estimate and try again. "
}


$s3 = $estimate.Groups.Services | Where-Object {$_.'Service Name' -eq 'S3 Standard'}
if ($s3 -and ($s3.Count -eq 1 )) {
Write-Output "`u{2705} Checking if public S3 storage is present in the estimate - OK. "
} else {
throw "`u{1F635} Unable to find S3 storage in the estimate. Please make sure that you added S3 storage to the estimate and try again. "
}
if ($s3.Properties.'S3 Standard storage' -eq '10 GB per month') {
Write-Output "`u{2705} Checking S3 storage capacity in the estimate - OK. "
} else {
throw "`u{1F635} Unable to validate S3 storage capacity. Please make sure that you added 10GB of S3 Standard storage to the estimate and try again. "
}


Write-Output ""
Write-Output "`u{1F973} Congratulations! All tests passed!"

0 comments on commit 650f801

Please sign in to comment.