Prerequisites:
- AWS Access and Secret keys with required privileges
- Terraform plugin installed into the local machine
- AWS CLI installed in local system
- An backend s3 bucket be created in the AWS account for keeping .tfstate file
- export aws credentials
# Linux
export AWS_ACCESS_KEY_ID=XXXXXXXXX
export AWS_SECRET_ACCESS_KEY=XXXXXXXXXXXXX
- Generate a SSH key-pair(This is required at the time of ssh)
ssh-keygen -m PEM -t rsa -b 2048 -f mediawiki
- Keep the private key with you and place the .pub key in the code. Lets keep it at /files/key_pairs/mediawiki.pub
- Clone the [repo] (https://github.com/dewshekhar/terraformed_mediawiki.git) and then Run
Terraform init
for initialization
- Run
terraform plan
it will show you the resources to be created, changed or deleted
- Run
terraform apply
to create the resources if everything looks good and pass an argument asyes
to confirm.
-
Wait till your resources be created.
-
Once resources gets created use the
endpoint
to access the mediawiki home page for installation
- Select the language
- Fill DB related details
- Download LocalSettings.php file
- SSH to the EC2 machine using the pem key which you have kept with you in step no 2.(I am using session manager as I had already attached the ssm related policies to the IAM role of Instance profile of EC2 )
- Copy the file to location
/var/www/html/mediawiki
.
- Ones copied click onto
enter your wiki
link available onto page where php file is downloaded you will be redirected to your wiki
- As this was only for demo purpose so after the activity destroy the infra.
Attributes:
1. Created aws core infra module for basic platfor setup
2. I have created all the resources in us-west-1 region
3. Instead of hardcopying the ami id I have used data element.
4. Kept my EC2 in private subnet and added load balancer in public subnet.(EC2 will only allow load balancer to communicate to its port 80)
5. Used the SSM to connect to EC2. for this purpose added the respective policies to EC2 instance profile's IAM role.
Issue:
1. We were getting issue with AMI which I used for initial setup as presently It is not available so used the data element instead of hardcoding.