Repository for AWS deployment with domain name and SSL
-
Register new AWS account with this guide. You need
email
,telephone
, andcredit card
(create and use a virtual one). -
Install aws cli. To validate:
aws --version
-
Install terraform. To validate:
terraform --version
-
Go to the aws console
-
Go to the User > Settings and change Default Region to
us-east-2
-
Change region to your default (and use it further)
-
Follow this guide to create user with administrator access and get credentials for aws cli.
-
Download them as
.csv
file and open file. -
Get
AccessKeyId
andSecretAccessKey
from this file (splited by commas) -
Open terminal and run
aws configure
-
Paste
AccessKeyId
,SecretAccessKey
. Default region:us-east-2
, enter. Default output:text
, enter. -
Delete
.csv
file for security
-
Go to the aws console.
-
Go to the Key pairs service.
-
Create key pair with some name (lets call it
key_name
). -
Move downloaded
key_name.pem
to the project root folder. -
Open infrastructure/main.tf and change variable
key_name
default to the name of your key.
-
Go to the site
-
Enter domain you want and check it
-
Find domain with "Get it now" button, copy it and paste in the search and check it again (search with extension like
domain.tk
) -
You should see checkout button, click it
-
Select period and click Continue
-
Enter email (can use fake one) and follow link in the email.
-
Use fake address generator for country where your ip located to generate address (example).
-
Enter data and complete order. If all is fine you won't get Technical error.
-
Log in to the site and go to Services > MyDomain > Manage Domain > Management Tools > Nameservers. Select use custom nameservers
-
Open infrastructure/main.tf and change variable
key_name
default to the name of your domain. -
Do not close this site, here you will enter aws nameservers from the generated infrastructure (from
.nameservers
file).
-
Go to the infrastructure/main.tf and check if variables and data comfortable for you.
-
Open terminal in root project folder.
-
Enter
cd infrastructure
and runsh deploy_infrastructure.sh
-
Wait for infrastructure to be deployed (if needed, confirm)
-
After ending, check
.infrastructure_output
file. There will be stored all necessary variables for deployment. -
Also, check
.nameservers
file. Here you will see nameservers, which can be used to fill in nameservers for your domain. -
To destroy created infrastructure run
terraform destroy
-
Create
.env
file and copy content from.infrastructure_output
-
Add variables
DOMAIN_NAME
(which you created before) andDOMAIN_EMAIL
(which will be used by certbot for maintenance), so the keys of.env
is equal to the.env.example
-
Be sure that you can access your ec2 instance with the domain
-
Open terminal in root project folder.
-
Run
deploy.sh
-
Access it with your domain, you should see text message.