Skip to content

Commit f636f76

Browse files
committed
Initial commit
1 parent f69249a commit f636f76

File tree

6 files changed

+152
-1
lines changed

6 files changed

+152
-1
lines changed

.github/workflows/deploy.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: Simple Deploy
2+
on:
3+
workflow_dispatch:
4+
push:
5+
branches:
6+
- main
7+
env:
8+
AWS_DEFAULT_REGION: "us-east-1"
9+
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID}}
10+
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
11+
jobs:
12+
apply:
13+
name: Terraform apply
14+
runs-on: ubuntu-latest
15+
steps:
16+
- name: Checkout repo
17+
uses: actions/checkout@v4
18+
- name: Get account ID
19+
run: |
20+
echo "account_id=$(aws sts get-caller-identity --query Account --output text)" >> "$GITHUB_ENV"
21+
- name: Create state bucket
22+
run: |
23+
if aws s3 ls s3://tf-"$account_id"; then
24+
exit
25+
else
26+
aws s3 mb s3://tf-"$account_id" --no-cli-auto-prompt
27+
fi
28+
- name: Install Terraform
29+
uses: hashicorp/setup-terraform@v3
30+
- name: Run Terraform
31+
run: |
32+
terraform init -backend-config="bucket=tf-"$account_id""
33+
terraform apply -auto-approve=true

.gitignore

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# Local .terraform directories
2+
**/.terraform/*
3+
4+
# .tfstate files
5+
*.tfstate
6+
*.tfstate.*
7+
8+
# Crash log files
9+
crash.log
10+
crash.*.log
11+
12+
# Exclude all .tfvars files, which are likely to contain sensitive data, such as
13+
# password, private keys, and other secrets. These should not be part of version
14+
# control as they are data points which are potentially sensitive and subject
15+
# to change depending on the environment.
16+
*.tfvars
17+
*.tfvars.json
18+
19+
# Ignore override files as they are usually used to override resources locally and so
20+
# are not checked in
21+
override.tf
22+
override.tf.json
23+
*_override.tf
24+
*_override.tf.json
25+
26+
# Include override files you do wish to add to version control using negated pattern
27+
# !example_override.tf
28+
29+
# Include tfplan files to ignore the plan output of command: terraform plan -out=tfplan
30+
# example: *tfplan*
31+
32+
# Ignore CLI configuration files
33+
.terraformrc
34+
terraform.rc

README.md

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,38 @@
1-
# js-full-stack-developer-exercise
1+
# In a nutshell:
2+
3+
This JS Fullstack Developer Challenge is brought to you by your friends at [Last Call Media](https://www.lastcallmedia.com), it is designed to assess your skills and to see how you solve problems. Please don't spend more than 2 hours working on it, and if you have trouble completing it in that time, don't stress about it - just push up whatever you have. There is no right answer here, and work-in-progress code is fine, as long as you can explain what you were working on afterwards.
4+
5+
You have full access to `us-east-1` and `us-west-2`. Credentials should have been provided separately. You can generate as many as you want but those expire after an hour. If you plug them into `credentials.sh` you'll get credentials back that don't expire.
6+
7+
---
8+
9+
### Your solution should:
10+
11+
- Deploy a Next.JS app that shows a video/screen recording of you summarizing your work on this project.
12+
- The video should be stored in S3.
13+
- Be reusable. It should be possible to apply it to any AWS account and GitHub repo with the necessary credentials
14+
- The site should be rebuilt upon pushes to this repository
15+
- Consider maintainability. The less maintenance it’ll require in the future, the better
16+
- Be fully automated with no steps that need to be completed in the console
17+
- Take security into account. Security is hard and your solution doesn’t need to be perfect. It’s ok to take some shortcuts if you call out what you’d do in production to make it safer
18+
- Be inexpensive
19+
20+
---
21+
22+
### Deliverables:
23+
24+
- A URL that can be accessed from the internet and prompts for a username and password
25+
- It’s fine if the URL contains an AWS-owned domain or an IP. After authenticating, the Next.JS site should be shown.
26+
- Username and password that we can use to authenticate
27+
- Link to the forked repo containing your solution
28+
- A README with a brief explanation of your solution and anything else you’d like us to know
29+
30+
**Please be prepared to talk about your solution and to help troubleshoot if we can’t make it work**
31+
32+
---
33+
34+
### Extras:
35+
36+
Some basic scaffolding you may find useful is included but please feel free to use other tools if you prefer.
37+
38+
We don't expect you to write the auth stuff. There are lots of examples on GitHub if you'd like to use one of those. [For example](https://gist.githubusercontent.com/jeroenvollenbrock/94edbbc62adc986d6d6a9a3076e66f5b/raw/259840af8dc2408f2be142588e41aebfa76c44b7/aws-cloudfront-basic-auth.js)

credentials.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/usr/bin/env bash
2+
3+
export AWS_ACCESS_KEY_ID=
4+
export AWS_SECRET_ACCESS_KEY=
5+
export AWS_SESSION_TOKEN=
6+
7+
aws iam create-user --user-name iamuser1
8+
aws iam attach-user-policy --user-name iamuser1 --policy-arn arn:aws:iam::aws:policy/AdministratorAccess
9+
aws iam create-access-key --user-name iamuser1

main.tf

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
terraform {
2+
backend "s3" {
3+
key = "tfstate"
4+
}
5+
}
6+
7+
provider "aws" {}
8+
9+
10+
# Below we import the state bucket made with GHA... into our own state
11+
# Just a quick check that everything works
12+
13+
data "aws_caller_identity" "current" {}
14+
15+
locals {
16+
account_id = data.aws_caller_identity.current.account_id
17+
}
18+
19+
import {
20+
to = aws_s3_bucket.tfstate
21+
id = "tf-${local.account_id}"
22+
}
23+
24+
resource "aws_s3_bucket" "tfstate" {
25+
bucket = "tf-${local.account_id}"
26+
}

web/index.html

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<title>Boy I wish I could make this webpage in Next.JS</title>
5+
</head>
6+
<body>
7+
<p>
8+
This is a webpage that I made in HTML. I wish I could make it in Next.JS
9+
instead.
10+
</p>
11+
</body>
12+
</html>

0 commit comments

Comments
 (0)