Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature request] Update a Route53 DNS record with the IP of the EC2 instance #68

Closed
mrumpf opened this issue Oct 2, 2023 · 2 comments

Comments

@mrumpf
Copy link

mrumpf commented Oct 2, 2023

Is your feature request related to a problem? Please describe.
Every time the Ec2 machine starts, a script could be run to update a configurable DNS record.

Describe the solution you'd like
I own a domain which I would like to use to make it easier to connect to the server by creating a record like minecraft.mydomain.cloud.

In the guide How to automatically update IP addresses a script is run at each boot to update a DNS record with the new IP address. The DNS name is added as a tag to the EC2 instance.
This could also be implemented as a Linux systemd service

An alternative solution would be to integrate the DNS update functionality into the Lambda function which posts the IP address into the Discord channel.

Whatever solution is implemented, the script could look at the EC2 instance tags and if there is a DNS_RECORD tag present it could execute the update Route53 dns record functionality. This would make this an optional feature, which can be controlled by giving an optional environment variable DNS_RECORD_TAG=minecraft.mydomain.cloud

@mrumpf
Copy link
Author

mrumpf commented Oct 2, 2023

BTW, the script in the linked guide shows a way how to get the public IP from inside the machine, without having to consult an external service like opendns.

@314pies
Copy link
Contributor

314pies commented Oct 2, 2023

Cool, I like this idea!

If anyone also interested in this feature, please leave a comment or reaction so we know you need it!

mrumpf added a commit to mrumpf/MineCloud that referenced this issue Oct 3, 2023
Implements VeriorPies#68

A DNS name is setup automatically when the parameter
DOMAIN_NAME is set to a name pointing to an existing
Hosted Zone. Setting up a hosted zone on AWS involves
purchasing a domain and paying a for it on a yearly
basis. This makes it hard to automate and is therefore
left out of the automation. Instead an existing
hosted zone is referenced by the value of the parameter
DOMAIN_NAME in the MineCloud-Service-Info.ts file.
When this parameter is set, an additional branch of
the CDK script gets executed, which assigns some
additional policies to the EC2 role to allow the VM
to lookup the hosted zone id to update the IP address
of the ARecord, which has been created by CDK.
The DNS name is derived by appending the value of
DOMAIN_NAME to the hostname "minecloud".
The DOMAIN_NAME is attached as a tag to the EC2 instance
to make it accessible to the start_service.sh script
which updates the ARecord with the assigned IP address.
The bot pushes the domain name to the Discord channel
only when the DOMAIN_NAME parameter has been set.

The changeset also includes a change to avoid the file
MineCloud-Service-Info.ts with all the private data
being committed to Git accidentally. Therefore the
file is renamed to MineCloud-Service-Info.ts.sample
and the README is updated to make a copy to the actual
name MineCloud-Service-Info.ts before setting all the
parameters. The MineCloud-Service-Info.ts is set to the
.gitignore list so that the actual file is ignored
upon git commits.
314pies pushed a commit that referenced this issue Oct 30, 2023
* Allow setting up a DNS name for the minecloud server

Implements #68

A DNS name is setup automatically when the parameter
DOMAIN_NAME is set to a name pointing to an existing
Hosted Zone. Setting up a hosted zone on AWS involves
purchasing a domain and paying a for it on a yearly
basis. This makes it hard to automate and is therefore
left out of the automation. Instead an existing
hosted zone is referenced by the value of the parameter
DOMAIN_NAME in the MineCloud-Service-Info.ts file.
When this parameter is set, an additional branch of
the CDK script gets executed, which assigns some
additional policies to the EC2 role to allow the VM
to lookup the hosted zone id to update the IP address
of the ARecord, which has been created by CDK.
The DNS name is derived by appending the value of
DOMAIN_NAME to the hostname "minecloud".
The DOMAIN_NAME is attached as a tag to the EC2 instance
to make it accessible to the start_service.sh script
which updates the ARecord with the assigned IP address.
The bot pushes the domain name to the Discord channel
only when the DOMAIN_NAME parameter has been set.

The changeset also includes a change to avoid the file
MineCloud-Service-Info.ts with all the private data
being committed to Git accidentally. Therefore the
file is renamed to MineCloud-Service-Info.ts.sample
and the README is updated to make a copy to the actual
name MineCloud-Service-Info.ts before setting all the
parameters. The MineCloud-Service-Info.ts is set to the
.gitignore list so that the actual file is ignored
upon git commits.

* Reverts a change that is not ready yet, accidentally committed

* Added some more comments
@314pies 314pies closed this as completed Oct 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants