fresh-spring-82225
06/10/2024, 5:21 PMmkfs
, mount
, etc. as described here? Or is there a streamlined way of doing all that?little-cartoon-10569
06/10/2024, 7:50 PMfresh-spring-82225
06/10/2024, 8:05 PMnew aws.ec2.LaunchTemplate(..., {
blockDeviceMappings: [
{
deviceName: '/dev/sdf',
ebs: {
volumeSize: 100,
},
},
],
When I create an instance from that template, it does create the ebs volume. But that volume doesn't have a filesystem and it isn't mounted — it's those parts I was asking about.little-cartoon-10569
06/10/2024, 8:34 PMgreat-sunset-355
06/10/2024, 9:04 PMuserdata
const pgDataVolume = new aws.ebs.Volume(
rcName("pgdata"),
{
availabilityZone: subnetOutput.availabilityZone,
size: 20,
type: "gp3",
encrypted: true,
},
{ parent },
);
new aws.ec2.VolumeAttachment(
rcName("pgdata-attachment"),
{
deviceName: "/dev/sdf",
instanceId: this.instance.id,
volumeId: pgDataVolume.id,
},
{ parent },
);
echo "Mounting PGDATA volume"
VOLUME_NAME=$(lsblk | grep disk | awk '{print $1}' | while read disk; do echo -n "$disk " && ebsnvme-id -b /dev/$disk; done | grep /dev/sdf | awk '{print $1}')
echo "VOLUME_NAME - $VOLUME_NAME"
MOUNT_POINT=$(lsblk -o MOUNTPOINT -nr /dev/$VOLUME_NAME)
echo "MOUNT_POINT - $MOUNT_POINT"
# if the volume is not mounted, mount it
if [[ -z "$MOUNT_POINT" ]]
then
MOUNT_POINT=/data
FILE_SYSTEM=$(lsblk -o FSTYPE -nr /dev/$VOLUME_NAME)
echo "FILE_SYSTEM - $FILE_SYSTEM"
if [[ $FILE_SYSTEM != 'xfs' ]]
then
mkfs -t xfs /dev/$VOLUME_NAME
fi
mkdir -p $MOUNT_POINT
mount /dev/$VOLUME_NAME $MOUNT_POINT
cp /etc/fstab /etc/fstab.orig
VOLUME_ID=$(lsblk -o UUID -nr /dev/$VOLUME_NAME)
if [[ ! -z $VOLUME_ID ]]
then
tee -a /etc/fstab <<EOF
UUID=$VOLUME_ID $MOUNT_POINT xfs defaults,nofail 0 2
EOF
fi
fi
echo "Mounting finished: $MOUNT_POINT"
export MOUNT_POINT=/data
export POSTGRES_DIR=$MOUNT_POINT/postgresql
fresh-spring-82225
06/10/2024, 9:06 PMlittle-cartoon-10569
06/10/2024, 9:07 PMlittle-cartoon-10569
06/10/2024, 9:07 PMgreat-sunset-355
06/10/2024, 9:12 PMNo matter how you like to participate in developer communities, Pulumi wants to meet you there. If you want to meet other Pulumi users to share use-cases and best practices, contribute code or documentation, see us at an event, or just tell a story about something cool you did with Pulumi, you are part of our community.
Powered by