Reputation: 2116
I want to add a custom search entry to the /etc/resolv.conf file in my EC2 instances when they start up.
I use Cloudformation to provision my servers. The file is already populated with one search entry by AWS so I just want to add a second entry to this line, like so:
search myCompany.com region.compute.internal
What is the best way to achieve this using cloudformation?
Upvotes: 2
Views: 800
Reputation: 999
With the user data parameter: that will do all necessary modifications to your instance at launch time. In your instance definition in the CloudFormation script, add something like this:
MyEC2Instance:
Type: AWS::EC2::Instance
Properties:
UserData:
Fn::Base64: !Sub |
#!/bin/bash
echo "search myCompany.com region.compute.internal" >> /etc/resolv.conf
Upvotes: 1