I have been using the Hashicorp vault on AWS EKS Fargate and want to use the AWS RDS Postgres as the persistent storage Backend so that all the data stored on the vault resides inside it.
I have been trying this setup for a quite long but am not successful. Please help me with the steps to do so if anyone has done this already on their end.
This is an example of a bad way to ask for help. You’ve provided no details whatsoever about the problems you’re experiencing.
You will generally not find volunteers with so much time on their hands, that they want to write lengthy custom walkthroughs for individual people.
On the other hand, if you are able to ask a specific question about a point at which you are stuck, you can benefit from people who will quickly offer some pointers to get you moving forwards again.
Here, the database details are of the AWS Postgres DB.
Created a file named init.sh
#!/bin/sh
vault server -config=/vault/config/config.hcl &
sleep 5
export VAULT_ADDR=http://localhost:8200
vault operator init -recovery-shares=1 -recovery-threshold=1 > /vault/keys.txt
echo "Initialization complete. Unseal key and initial root token are saved in /vault/keys.txt"
tail -f /dev/null
Created a file named Dockerfile.
FROM vault:latest
# Install PostgreSQL client
RUN apk add --no-cache postgresql-client
# Copy and set up configuration files
COPY config.hcl /vault/config/
COPY init.sh /vault/
# Set necessary environment variables
ENV VAULT_LOCAL_CONFIG=/vault/config/config.hcl
ENV VAULT_ADDR=http://localhost:8200
# Expose the Vault server port
EXPOSE 8200
# Run the initialization script
ENTRYPOINT ["/vault/init.sh"]
Then run the following commands to build the image.
docker build -t deshvaultimage .
And Run the container using the image build.
docker run -d -p 8200:8200 --name deshvaultcontainer deshvaultimage
Used localhost:8200 on my local PC but there was no output.
Please help me know where I am making mistakes or need to configure something extra.
I am new to Hashicorp vault and struggling to implement it with postgresdb as a backend.
The following is the error form the docker container of vault running.
Error initializing storage of type postgresql: failed to check for native upsert: cannot parse `postgresql://postgres:xxxxxx@vaultpostgres.c7gtihcllucp.us-east-1.rds.amazonaws.com:5432/vaultdb`: failed to parse as URL (parse "postgresql://postgres:admin": invalid port ":admin" after host)
2023-06-19T05:31:09.132Z [INFO] proxy environment: http_proxy="" https_proxy="" no_proxy=""
Get "http://localhost:8200/v1/sys/seal-status": dial tcp 127.0.0.1:8200: connect: connection refused
Initialization complete. Unseal key and initial root token are saved in /vault/keys.txt
Thank you, that worked. And now I can see the vault on my browser at localhost:8200.
But I am not able to get the keys at the specified location which said “Unseal key and initial root token are saved in /vault/keys.txt”
This is the error that I am getting.
==> Vault server started! Log data will stream in below:
2023-06-19T09:04:13.552Z [INFO] core: security barrier not initialized
2023-06-19T09:04:13.830Z [INFO] core: seal configuration missing, not initialized
Error initializing: Error making API request.
URL: PUT http://localhost:8200/v1/sys/init
Code: 400. Errors:
* parameters recovery_shares,recovery_threshold not applicable to seal type shamir
Initialization complete. Unseal key and initial root token are saved in /vault/keys.txt
2023-06-19T09:04:16.129Z [INFO] core: security barrier not initialized
2023-06-19T09:04:16.403Z [INFO] core: seal configuration missing, not initialized
2023-06-19T09:04:19.593Z [INFO] core: security barrier not initialized
2023-06-19T09:04:31.126Z [INFO] core: security barrier not initialized
2023-06-19T09:04:31.128Z [INFO] core: security barrier not initialized