Skip to content

Instantly share code, notes, and snippets.

@grrywlsn
Created October 27, 2016 21:42
Show Gist options
  • Save grrywlsn/70397e22f20d2401c85f5314d9addb5d to your computer and use it in GitHub Desktop.
Save grrywlsn/70397e22f20d2401c85f5314d9addb5d to your computer and use it in GitHub Desktop.
Mounting EFS to CoreOS instances with the matching zone DNS endpoint automatically
#cloud-config
write_files:
- path: /etc/conf.d/nfs
permissions: '0644'
content: |
OPTS_RPC_MOUNTD=""
coreos:
units:
- name: rpc-statd.service
command: start
enable: true
- name: mnt-efs.mount
content: |
[Mount]
What=AZ_ZONE.fs-[EFS-ID].efs.eu-west-1.amazonaws.com:/
Where=/mnt/efs
Type=nfs
- name: efs-az.service
command: start
content: |
[Unit]
Description=mount EFS in this AZ
[Service]
Type=oneshot
ExecStart=/bin/sh -c "AZ_ZONE=$(curl -L http://169.254.169.254/latest/meta-data/placement/availability-zone); sed -i \"s/AZ_ZONE/$AZ_ZONE/\" /etc/systemd/system/mnt-efs.mount; systemctl daemon-reload; systemctl restart mnt-efs.mount"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment