Launching the ATC Manager |
Custom scripts are set by expanding the Advanced Detail section on the Configure Instance Details page when launching the ATC Manager AMI. (To review how to launch a cluster, see Launching the ATC Manager AMI.)
To create custom scripts, the RDS database for use with the cluster must already be created so that you can specify your RDS endpoint URL. For more information, see Creating the RDS Database.
Scripts are added in the User Data field after the instance user data and the -----SCRIPT----- separator. The SCRIPT separator must have exactly five dashes on each side. The following examples provide guides for typical configurations.
Use the following script to automatically assign a specific Internal IP to your ATC Manager. Replace your_rds_endpoint_url and your_ip_address with their actual values.
{ "restore": true, "statestore_backup_period": "1m", "database": { "host": "your_rds_endpoint_url", "port": 3306, "user": "db_username", "password": "db_password" } } -----SCRIPT----- #!/bin/bash # # Attach a secondary private IP address to eth0 on AWS EC2. # # the IP to use ip=your_ip_address curl="curl -sS http://169.254.169.254/2014-11-05" region=$($curl/dynamic/instance-identity/document/ | jq --raw-output '.region') macs=$($curl/meta-data/network/interfaces/macs/) while read -r mac; do device_number=$($curl/meta-data/network/interfaces/macs/$mac/device-number/) if [ "$device_number" -eq "0" ]; then eni_id=$($curl/meta-data/network/interfaces/macs/$mac/interface-id/) aws ec2 assign-private-ip-addresses --region "$region" --network-interface-id "$eni_id" --private-ip-addresses $ip fi done <<< "$macs" echo "DEVICE=eth0:1 BOOTPROTO=static ONBOOT=yes IPADDR=$ip NETMASK=255.255.255.0" > /etc/sysconfig/network-scripts/ifcfg-eth0:1 ifup eth0:1 # set the ip in the cluster manager configuration echo "$(jq --arg ip "$ip" '.private_ip |= $ip' /opt/aspera/atcm/etc/atc-api.conf)" > /opt/aspera/atcm/etc/atc-api.conf
Use the following script to automatically assign a specific Elastic IP to your ATC Manager. Replace your_rds_endpoint_url and your_eip_allocation_id with their actual values.
{ "restore": true, "statestore_backup_period": "1m", "database": { "host": "your_rds_endpoint_url", "port": 3306, "user": "db_username", "password": "db_password" } } -----SCRIPT----- #!/bin/bash # assign elastic IP eip=your_eip_allocation_id curl="curl -sS http://169.254.169.254/2014-11-05" region=$($curl/dynamic/instance-identity/document/ | jq --raw-output '.region') instance_id=$($curl/dynamic/instance-identity/document/ | jq --raw-output '.instanceId') aws ec2 associate-address --region "$region" --instance-id "$instance_id" --allocation-id "$eip" --allow-reassociation
Use the following script to assign an ELB to your ATC Manager. Replace your_rds_endpoint_url and your_elb_name with their actual values. This script automatically retrieves the ELB DNS name using the ELB name.
{ "restore": true, "statestore_backup_period": "1m", "database": { "host": "your_rds_endpoint_url", "port": 3306, "user": "db_username", "password": "db_password" } } -----SCRIPT----- #!/bin/bash # assign elastic load balancer elb="your_elb_name" curl="curl -sS http://169.254.169.254/2014-11-05/" region=$($curl/dynamic/instance-identity/document/ | jq --raw-output '.region') instance_id=$($curl/meta-data/instance-id) aws elb register-instances-with-load-balancer --region="$region" --load-balancer-name "$elb" --instances "$instance_id" elb_dnsname="$(aws elb describe-load-balancers --region="$region" | jq --arg elb "$elb" --raw-output '.LoadBalancerDescriptions[] | select(.LoadBalancerName == $elb) | .DNSName')" echo "$(jq --arg elb_dnsname "$elb_dnsname" '.private_ip |= $elb_dnsname' /opt/aspera/atcm/etc/atc-api.conf)" > /opt/aspera/atcm/etc/atc-api.conf
Use the following script to automatically tag EBS volumes that are created by nodes in you ATC Manager. Replace your_rds_endpoint_url with its actual value, your_tag_name with a descriptor such as Name, and your_tag_value with a value such as EBS_from_ATCM.
{ "restore": true, "statestore_backup_period": "1m", "database": { "host": "your_rds_endpoint_url", "port": 3306, "user": "db_username", "password": "db_password" } } -----SCRIPT----- #!/bin/bash # tag new ebs volumes Key=your_tag_name Value=your_tag_value Region=$(curl -sS http://169.254.169.254/2014-11-05/dynamic/instance-identity/document/ | jq --raw-output '.region') Instance=$(curl -sS http://169.254.169.254/latest/meta-data/instance-id) Volume=$(aws ec2 describe-instances --instance-ids $Instance --region $Region | jq --raw-output '.Reservations[].Instances[].BlockDeviceMappings[].Ebs.VolumeId') aws ec2 create-tags --resources $Volume --tags Key=$Key,Value=$Value --region $Region