[java-parent-project] branch main updated: Add script to manage an EC2 instance's A record.

Codeberg noreply at shibboleth.net
Wed Dec 3 18:05:49 UTC 2025


This is an automated email from the git hooks/post-receive script.

codeberg pushed a commit to branch main
in repository java-parent-project.

View the commit online:
https://codeberg.org/Shibboleth/java-parent-project/commit/5fc9efcbc6a546f8905ee58dc479ee4d4f329a7f

The following commit(s) were added to refs/heads/main by this push:
     new 5fc9efc  Add script to manage an EC2 instance's A record.
5fc9efc is described below

commit 5fc9efcbc6a546f8905ee58dc479ee4d4f329a7f
Author: Scott Cantor <cantor.2 at osu.edu>
AuthorDate: Wed Dec 3 13:05:20 2025 -0500

    Add script to manage an EC2 instance's A record.
---
 bin/update-route53.sh | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/bin/update-route53.sh b/bin/update-route53.sh
new file mode 100755
index 0000000..03490cf
--- /dev/null
+++ b/bin/update-route53.sh
@@ -0,0 +1,20 @@
+#!/bin/env bash
+
+# Extracts instance metadata and uses it to update an A record in a Route53 zone
+# Requires an IAM role that can read instance tags and update a zone.
+
+# Get a token.
+TOKEN=${curl -s -X PUT "http://169.254.169.254/latest/api/token" -H "X-aws-ec2-metadata-token-ttl-seconds: 300"}
+
+# Extract information about the Instance
+INSTANCE_ID=$(curl -H "X-aws-ec2-metadata-token: $TOKEN" -s http://169.254.169.254/latest/meta-data/instance-id/)
+AZ=$(curl -H "X-aws-ec2-metadata-token: $TOKEN" -s http://169.254.169.254/latest/meta-data/placement/availability-zone/)
+MY_IP=$(curl -H "X-aws-ec2-metadata-token: $TOKEN" -s http://169.254.169.254/latest/meta-data/public-ipv4/)
+
+# Extract tags associated with instance
+ZONE_TAG=$(aws ec2 describe-tags --region ${AZ::-1} --filters "Name=resource-id,Values=${INSTANCE_ID}" --query 'Tags[?Key==`AUTO_DNS_ZONE`].Value' --output text)
+NAME_TAG=$(aws ec2 describe-tags --region ${AZ::-1} --filters "Name=resource-id,Values=${INSTANCE_ID}" --query 'Tags[?Key==`AUTO_DNS_NAME`].Value' --output text)
+
+# Update Route 53 Record Set based on the Name tag to the current Public IP address of the Instance
+aws route53 change-resource-record-sets --hosted-zone-id $ZONE_TAG --change-batch '{"Changes":[{"Action":"UPSERT","ResourceRecordSet":{"Name":"'$NAME_TAG'","Type":"A","TTL":300,"ResourceRecords":[{"Value":"'$MY_IP'"}]}}]}'
+

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the commits mailing list