3.2 KiB
		
	
	
	
	
	
	
	
			
		
		
	
	Method 1 - Build Locally and Import to AWS
This method involves using Terraform to bring DetectionLab infrastructure online by first building it locally using Virtualbox/VMware and then importing the resulting virtual machines as AMIs on AWS.
The supplied Terraform configuration can then be used to create EC2 instances and all requisite networking components.
Prerequisites
- A machine to build DetectionLab with
- An AWS account
- An AWS user and access keys to use with the AWS CLI
- Optional but recommended: a separate user for Terraform
Step by step guide
- 
Build the lab by following the README 
- 
Create an S3 bucket. You will upload the DetectionLab VMs to this bucket later. 
- 
For the VM importation to work, you must create a role named vmimportwith a trust relationship policy document that allows VM Import to assume the role, and you must attach an IAM policy to the role:
aws iam create-role --role-name vmimport --assume-role-policy-document file:///path/to/DetectionLab/Terraform/vm_import/trust-policy.json
- 
Edit /path/to/DetectionLab/Terraform/vm_import/role-policy.jsonand insert the name of the bucket you created in step 3 on lines 12-13, replacingYOUR_BUCKET_GOES_HEREwith the name of your bucket.
- 
Use the create-role command to create a role named vmimport and give VM Import/Export access to it: 
aws iam put-role-policy --role-name vmimport --policy-name vmimport --policy-document file:///path/to/DetectionLab/Terraform/vm_import/role-policy.json
- Export the DetectionLab VMs as single file OVA files if they are not already in that format
- Upload the OVAs to the S3 bucket you created in step three
- Edit the logger.json,dc.json,wef.jsonandwin10.jsonfiles and modify the S3Bucket and S3Key headers to match the location of the OVA files in your S3 bucket.
- Import the VMs from S3 as AMIs by running the following commands:
aws ec2 import-image --description "dc" --license-type byol --disk-containers file:///path/to/DetectionLab/Terraform/vm_import/dc.json
aws ec2 import-image --description "wef" --license-type byol --disk-containers file:///path/to/DetectionLab/Terraform/vm_import/wef.json
aws ec2 import-image --description "win10" --license-type byol --disk-containers file:///path/to/DetectionLab/Terraform/vm_import/win10.json
aws ec2 import-image --description "logger" --license-type byol --disk-containers file:///path/to/DetectionLab/Terraform/vm_import/logger.json
- Check on the status of the importation with the following command:
aws ec2 describe-import-image-tasks --import-task-ids <import-ami-xxxxxxxxxxxxxxxxx>
- Fill out the variables in /path/to/DetectionLab/Terraform/terraform.tfvars
- Run terraform initto setup the initial Terraform configuration
- cd /path/to/DetectionLab/Terraform/Method1 && terraform apply
