|
|
8b04f5 |
--- ClusterLabs-resource-agents-e711383f/heartbeat/aws-vpc-move-ip 2020-09-23 11:57:38.855067216 +0200
|
|
|
8b04f5 |
+++ aws-vpc-move-ip.tmp 2020-09-23 11:57:17.993045991 +0200
|
|
|
8b04f5 |
@@ -37,13 +37,17 @@
|
|
|
8b04f5 |
# Defaults
|
|
|
8b04f5 |
OCF_RESKEY_awscli_default="/usr/bin/aws"
|
|
|
8b04f5 |
OCF_RESKEY_profile_default="default"
|
|
|
8b04f5 |
+OCF_RESKEY_region_default=""
|
|
|
8b04f5 |
OCF_RESKEY_routing_table_role_default=""
|
|
|
8b04f5 |
OCF_RESKEY_monapi_default="false"
|
|
|
8b04f5 |
|
|
|
8b04f5 |
: ${OCF_RESKEY_awscli=${OCF_RESKEY_awscli_default}}
|
|
|
8b04f5 |
: ${OCF_RESKEY_profile=${OCF_RESKEY_profile_default}}
|
|
|
8b04f5 |
+: ${OCF_RESKEY_region=${OCF_RESKEY_region_default}}
|
|
|
8b04f5 |
: ${OCF_RESKEY_routing_table_role=${OCF_RESKEY_routing_table_role_default}}
|
|
|
8b04f5 |
: ${OCF_RESKEY_monapi=${OCF_RESKEY_monapi_default}}
|
|
|
8b04f5 |
+
|
|
|
8b04f5 |
+[ -n "$OCF_RESKEY_region" ] && region_opt="--region $OCF_RESKEY_region"
|
|
|
8b04f5 |
#######################################################################
|
|
|
8b04f5 |
|
|
|
8b04f5 |
|
|
|
8b04f5 |
@@ -87,6 +91,14 @@
|
|
|
8b04f5 |
<content type="string" default="${OCF_RESKEY_profile_default}" />
|
|
|
8b04f5 |
</parameter>
|
|
|
8b04f5 |
|
|
|
8b04f5 |
+<parameter name="region">
|
|
|
8b04f5 |
+<longdesc lang="en">
|
|
|
8b04f5 |
+Valid AWS region name (e.g., 'us-west-2')
|
|
|
8b04f5 |
+</longdesc>
|
|
|
8b04f5 |
+<shortdesc lang="en">region name</shortdesc>
|
|
|
8b04f5 |
+<content type="string" default="${OCF_RESKEY_region_default}" />
|
|
|
8b04f5 |
+</parameter>
|
|
|
8b04f5 |
+
|
|
|
8b04f5 |
<parameter name="ip" required="1">
|
|
|
8b04f5 |
<longdesc lang="en">
|
|
|
8b04f5 |
VPC private IP address
|
|
|
8b04f5 |
@@ -151,7 +163,7 @@
|
|
|
8b04f5 |
execute_cmd_as_role(){
|
|
|
8b04f5 |
cmd=$1
|
|
|
8b04f5 |
role=$2
|
|
|
8b04f5 |
- output="$($OCF_RESKEY_awscli sts assume-role --role-arn $role --role-session-name AWSCLI-RouteTableUpdate --profile $OCF_RESKEY_profile --output=text)"
|
|
|
8b04f5 |
+ output="$($OCF_RESKEY_awscli sts assume-role --role-arn $role --role-session-name AWSCLI-RouteTableUpdate --profile $OCF_RESKEY_profile $region_opt --output=text)"
|
|
|
8b04f5 |
export AWS_ACCESS_KEY_ID="$(echo $output | awk -F" " '$4=="CREDENTIALS" {print $5}')"
|
|
|
8b04f5 |
export AWS_SECRET_ACCESS_KEY="$(echo $output | awk -F" " '$4=="CREDENTIALS" {print $7}')"
|
|
|
8b04f5 |
export AWS_SESSION_TOKEN="$(echo $output | awk -F" " '$4=="CREDENTIALS" {print $8}')"
|
|
|
8b04f5 |
@@ -198,11 +210,11 @@
|
|
|
8b04f5 |
for rtb in $(echo $OCF_RESKEY_routing_table | sed -e 's/,/ /g'); do
|
|
|
8b04f5 |
ocf_log info "monitor: check routing table (API call) - $rtb"
|
|
|
8b04f5 |
if [[ -z "${OCF_RESKEY_routing_table_role}" ]]; then
|
|
|
8b04f5 |
- cmd="$OCF_RESKEY_awscli --profile $OCF_RESKEY_profile --output text ec2 describe-route-tables --route-table-ids $rtb --query RouteTables[*].Routes[?DestinationCidrBlock=='$OCF_RESKEY_ip/32'].InstanceId"
|
|
|
8b04f5 |
+ cmd="$OCF_RESKEY_awscli --profile $OCF_RESKEY_profile $region_opt --output text ec2 describe-route-tables --route-table-ids $rtb --query RouteTables[*].Routes[?DestinationCidrBlock=='$OCF_RESKEY_ip/32'].InstanceId"
|
|
|
8b04f5 |
ocf_log debug "executing command: $cmd"
|
|
|
8b04f5 |
ROUTE_TO_INSTANCE="$($cmd)"
|
|
|
8b04f5 |
else
|
|
|
8b04f5 |
- cmd="$OCF_RESKEY_awscli --output text ec2 describe-route-tables --route-table-ids $rtb --query RouteTables[*].Routes[?DestinationCidrBlock=='$OCF_RESKEY_ip/32'].InstanceId"
|
|
|
8b04f5 |
+ cmd="$OCF_RESKEY_awscli $region_opt --output text ec2 describe-route-tables --route-table-ids $rtb --query RouteTables[*].Routes[?DestinationCidrBlock=='$OCF_RESKEY_ip/32'].InstanceId"
|
|
|
8b04f5 |
ROUTE_TO_INSTANCE="$(execute_cmd_as_role "$cmd" $OCF_RESKEY_routing_table_role)"
|
|
|
8b04f5 |
fi
|
|
|
8b04f5 |
ocf_log debug "Overlay IP is currently routed to ${ROUTE_TO_INSTANCE}"
|
|
|
8b04f5 |
@@ -283,11 +295,11 @@
|
|
|
8b04f5 |
|
|
|
8b04f5 |
for rtb in $(echo $OCF_RESKEY_routing_table | sed -e 's/,/ /g'); do
|
|
|
8b04f5 |
if [[ -z "${OCF_RESKEY_routing_table_role}" ]]; then
|
|
|
8b04f5 |
- cmd="$OCF_RESKEY_awscli --profile $OCF_RESKEY_profile --output text ec2 replace-route --route-table-id $rtb --destination-cidr-block ${OCF_RESKEY_ip}/32 --network-interface-id $EC2_NETWORK_INTERFACE_ID"
|
|
|
8b04f5 |
+ cmd="$OCF_RESKEY_awscli --profile $OCF_RESKEY_profile $region_opt --output text ec2 replace-route --route-table-id $rtb --destination-cidr-block ${OCF_RESKEY_ip}/32 --network-interface-id $EC2_NETWORK_INTERFACE_ID"
|
|
|
8b04f5 |
ocf_log debug "executing command: $cmd"
|
|
|
8b04f5 |
$cmd
|
|
|
8b04f5 |
else
|
|
|
8b04f5 |
- cmd="$OCF_RESKEY_awscli --output text ec2 replace-route --route-table-id $rtb --destination-cidr-block ${OCF_RESKEY_ip}/32 --network-interface-id $EC2_NETWORK_INTERFACE_ID"
|
|
|
8b04f5 |
+ cmd="$OCF_RESKEY_awscli $region_opt --output text ec2 replace-route --route-table-id $rtb --destination-cidr-block ${OCF_RESKEY_ip}/32 --network-interface-id $EC2_NETWORK_INTERFACE_ID"
|
|
|
8b04f5 |
update_response="$(execute_cmd_as_role "$cmd" $OCF_RESKEY_routing_table_role)"
|
|
|
8b04f5 |
fi
|
|
|
8b04f5 |
rc=$?
|
|
|
8b04f5 |
@@ -397,7 +409,7 @@
|
|
|
8b04f5 |
ec2ip_monitor;;
|
|
|
8b04f5 |
validate-all)
|
|
|
8b04f5 |
exit $?;;
|
|
|
8b04f5 |
- *)
|
|
|
8b04f5 |
+ *)
|
|
|
8b04f5 |
echo $USAGE
|
|
|
8b04f5 |
exit $OCF_ERR_UNIMPLEMENTED
|
|
|
8b04f5 |
;;
|