smiling iliyas
smiling iliyas

Reputation: 107

Need to add content to the resolv.conf based on region through cloudformation template

I have to update the content in resolv.conf based upon the region selection through cloudformation template.

Example nameserver 0.0.0.0

the above content need to add in resolv.conf based upon region If I will select US then the nameserver will be different and if it is EU then it will be different

I need how to write this condition in cloudformation template.

Please help me in this.

Thanks

Upvotes: 0

Views: 123

Answers (1)

zzenonn
zzenonn

Reputation: 58

My suggestion would be to put it in the userdata and put a mapping to map the appropriate region to nameserver. Something like

UserData:
  Fn::Base64: !Sub 
      - |
        #!/bin/bash 
        nameserver=${nameserver}
        echo "nameserver $nameserver" >> /etc/resolvconf/resolv.conf.d/base
      - nameserver: !FindInMap
          - RegionMap
          - !Ref "AWS::Region"
          - nameserver

You will need to declare a RegionMap in mappings to map each region with the appropriate nameserver.

Upvotes: 1

Related Questions