-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Introducing a dedicated bootstrap lab #11
Merged
Merged
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
# Getting started | ||
|
||
Let’s get started by bootstrapping Terraform and out AWS environment. | ||
|
||
## AWS credentials setup | ||
|
||
Before you start you will need | ||
|
||
- an AWS account that you can safely use during this workshop | ||
- administrator credentials to this account | ||
- install the aws cli according to the [documentation](https://docs.aws.amazon.com/cli/latest/userguide/getting-started-install.html) | ||
|
||
If you already have a mechanism in place for allowing access to AWS accounts (like SAML or AWS SSO), please use this. | ||
Otherwise, you can create an IAM users as described [here](https://docs.aws.amazon.com/cli/latest/userguide/getting-started-prereqs.html#getting-started-prereqs-iam). | ||
|
||
Lastly you have to publish your credentials to your shell environment. If you created an IAM user earlier, | ||
you can follow [this guide](https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-files.html#cli-configure-files-methods) | ||
to configure your credentials with the `aws configure` command. | ||
|
||
### Test your credentials setup | ||
|
||
To make sure that your environment is set up correctly, you can use the following command: | ||
|
||
```shell | ||
$ aws sts get-caller-identity | ||
{ | ||
"UserId": "AIDASAMPLEUSERID", | ||
"Account": "123456789012", | ||
"Arn": "arn:aws:iam::123456789012:user/DevAdmin" | ||
} | ||
``` | ||
|
||
You should make sure, that the field `Account` has the same account id that you wanted to use. | ||
|
||
## Bootstrap Terraform | ||
|
||
### Install Terraform | ||
|
||
During this workshop we will be using the terraform cli. To install we recommend that you use the | ||
[terraform version manager tfenv](https://github.com/tfutils/tfenv). | ||
|
||
You can now install terraform using tfenv | ||
|
||
```shell | ||
$ tfenv install 1.1.9 | ||
``` | ||
|
||
Test if you are using the correct version afterwards | ||
|
||
```shell | ||
$ terraform --version | ||
Terraform v1.1.9 | ||
... | ||
``` | ||
|
||
### Bootstrap the Terraform project | ||
|
||
1. Create a new folder and cd into it. | ||
1. Create a new file `main.tf` | ||
2. Add these lines to the `main.tf`: | ||
```tf | ||
terraform { | ||
required_version = "~> 1.1.7" | ||
} | ||
|
||
provider "aws" { | ||
region = "eu-central-1" | ||
} | ||
``` | ||
3. Run `terraform init` | ||
|
||
You should see some output similar to this: | ||
```shell | ||
$ terraform init | ||
|
||
Initializing the backend... | ||
|
||
Initializing provider plugins... | ||
- Finding latest version of hashicorp/aws... | ||
- Installing hashicorp/aws v4.27.0... | ||
- Installed hashicorp/aws v4.27.0 (signed by HashiCorp) | ||
|
||
Terraform has created a lock file .terraform.lock.hcl to record the provider | ||
selections it made above. Include this file in your version control repository | ||
so that Terraform can guarantee to make the same selections by default when | ||
you run "terraform init" in the future. | ||
|
||
Terraform has been successfully initialized! | ||
... | ||
``` | ||
## Next | ||
|
||
Our AWS environment and the terraform project is now properly set up. In the [next lab](../1-getting-started/), we can start deploying a first resource to our AWS account. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,10 @@ | ||
# Getting started | ||
|
||
Let’s get started by bootstrapping Terraform and deploying some resources to AWS. Instead of just deploying some random resources, we want to create an S3 bucket and enable static website hosting. Ultimately, we serve a static HTML file. | ||
Let’s get started by deploying some resources to AWS. Instead of just deploying some random resources, we want to create an S3 bucket and enable static website hosting. Ultimately, we serve a static HTML file. | ||
|
||
## Bootstrap Terraform | ||
## Creating a first bucket | ||
|
||
1. Create a new folder and cd into it. | ||
1. Create a new file `main.tf` | ||
2. Add these lines to the `main.tf`: | ||
```tf | ||
terraform { | ||
required_version = "~> 1.1.7" | ||
} | ||
|
||
provider "aws" { | ||
region = "eu-central-1" | ||
} | ||
``` | ||
3. Run `terraform init` | ||
4. Replace the `main.tf` file by adding the first resource: | ||
1. Replace the `main.tf` file by adding the first resource: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah ok I think now I understand. The steps should be followed in a separate folder instead of switching von |
||
```tf | ||
terraform { | ||
required_version = "~> 1.1.7" | ||
|
@@ -34,7 +21,7 @@ Let’s get started by bootstrapping Terraform and deploying some resources to A | |
force_destroy = true | ||
} | ||
``` | ||
5. Run `terraform apply` and confirm the deployment with `yes`. | ||
2. Run `terraform apply` and confirm the deployment with `yes`. | ||
|
||
We just created an empty S3 bucket. Go to the [S3 console](https://s3.console.aws.amazon.com/s3/buckets) and verify the existence. | ||
|
||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why a new folder? aren't we already in
0-bootstrap
and could do it in here?