Launching the Cluster Manager |
Insert the custom script into the instance user data after . Make sure the separator has exactly five dashes on each side.
These scripts are set by expanding the Advanced Detail section on the Configure Instance Details page when launching the Cluster Manager AMI. (To review how to launch a cluster, see Launching the Cluster Manager AMI.) Scripts are added in the User Data field after the instance user data and the -----SCRIPT----- separator. See below for examples of custom scripts.
Before continuing, make sure you have created the RDS database to use with the cluster. You need your RDS endpoint URL to finish this configuration. For more information, see Creating the RDS Database.
This example script can be used to automatically assign a specific Internal IP to your Cluster Manager. You must replace your_rds_endpoint_url and your_ip_address in the following script.
{ "restore": true, "statestore_backup_period": "1m", "database": { "host": "your_rds_endpoint_url", "port": 3306, "user": "root", "password": "secret" } } -----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
This example script can be used to automatically assign a specific Elastic IP to your Cluster Manager. You must replace your_rds_endpoint_url and your_eip_allocation_id in the following script.
{ "restore": true, "statestore_backup_period": "1m", "database": { "host": "your_rds_endpoint_url", "port": 3306, "user": "root", "password": "secret" } } -----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
This example script can be used to assign an Elastic Load Balancer to your Cluster Manager. You must replace your_rds_endpoint_url and your_elb_name in the following script.
{ "restore": true, "statestore_backup_period": "1m", "database": { "host": "your_rds_endpoint_url", "port": 3306, "user": "root", "password": "secret" } } -----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" echo "$(jq --arg elb "$elb" '.private_ip |= $elb' /opt/aspera/atcm/etc/atc-api.conf)" > /opt/aspera/atcm/etc/atc-api.conf