Database password rotation with AWS Secrets Manager and Spring Boot

Поделиться
HTML-код
  • Опубликовано: 5 авг 2024
  • Depending on how serious you are about security you may want to consider setting up password rotation for databases. If you're on AWS - they've got you covered! AWS Secrets Manager comes with support for automatic password rotation for RDS (and other database services).
    In this video I am showing how to set up RDS instance, how to set up password rotation for it using AWS Secrets Manager and how to connect Spring Boot application using very handy library - AWS Secrets Manager JDBC: github.com/aws/aws-secretsman...
    In my channel I discuss things I believe are relevant to either Java & Spring beginners, or advanced developers who want to stay up to date. Feedback is very much welcome!
    and shhhh follow me on twitter / maciejwalkowiak 😎
    --
    Music:
    raspberry soda by till / tillbeats
    Music provided by Free Music for Vlogs • (Free Music for Vlogs)...
  • НаукаНаука

Комментарии • 64

  • @dvaderjava666
    @dvaderjava666 4 года назад +4

    The real question is: why did you stop making these videos? Last one in the channel (the current one) is 9 months old. The material is really good and to the point and really useful for learning about Spring and AWS. I specially liked the one about LocalStack and TestContainers.

  • @ranajitjana4030
    @ranajitjana4030 4 года назад +1

    In case you can point to all the documentation from with you have made this it will help. This effort too was quite helpful. Thank you for posting

  • @amrutprabhu474
    @amrutprabhu474 3 года назад +6

    This was what I was looking for.. really helped me... great explanation .. Subscribed!

    • @SpringAcademy
      @SpringAcademy  3 года назад

      Awesome! Thanks for feedback I'm very happy to have you here 🙂

  • @mykolaskucinskas9473
    @mykolaskucinskas9473 Год назад

    Really great tutorial. Thank you for showing the alternative (aws-secretsmanager-jdbc library) to that Java code snippet.

  • @bbNganNguyen
    @bbNganNguyen 4 года назад

    Thank you so much for this awesowe video.

  • @ntarunmenon1
    @ntarunmenon1 5 лет назад +2

    Thanks for the excellent video.

  • @sitharamantr1072
    @sitharamantr1072 Год назад

    The real good one. Thanks

  • @Anbu_Sampath
    @Anbu_Sampath 5 лет назад +1

    As usual great content.

  • @altro5067
    @altro5067 5 лет назад +2

    Really like your video format!

  • @OlegKosmakov
    @OlegKosmakov 4 года назад +6

    I have to add it's not that the AWS maintains 2 passwords at once so that you can connect. What happened really is that the connection was already open when the password changed, therefore it continued to work. Until the program restart, of course.

  • @Harshal625
    @Harshal625 4 года назад

    Nice video...

  • @llama7206
    @llama7206 3 года назад

    golden tutorial

  • @-indeed8285
    @-indeed8285 5 лет назад

    Welcome back

    • @SpringAcademy
      @SpringAcademy  5 лет назад +2

      Thanks! If it pays my bills I could do it full time ;)

  • @rimurutempest9921
    @rimurutempest9921 2 года назад +1

    well explained

  • @mannanahmad3794
    @mannanahmad3794 4 года назад

    Nice video, i was struggling to write lambda. But now i came to know lambda is automatically written

  • @pavankumarnimmagadda2022
    @pavankumarnimmagadda2022 3 года назад

    Is something similar available for ruby to connect to postgres? So that the password can be pulled dynamically and secret rotation also talen care.

  • @jdkim7036
    @jdkim7036 4 года назад

    Do you have any solution without server reboot to adjust db properties instantly?

  • @amirmuhsin
    @amirmuhsin 4 года назад +2

    Maaaaaaan, you must come back! Why are you taking such a big break between your videos ???
    I thought I finally found awesome content about Spring boot.
    We need you. Please come back :)
    Or if you have some paid courses, give us a link.

    • @SpringAcademy
      @SpringAcademy  4 года назад +2

      Thank you! From mid February if all goes well I'll have dedicated time for Spring Academy so stay tuned 🙂

  • @inaslohith3678
    @inaslohith3678 Год назад

    After rotating secret in secret manager, do we not needed to update the new password in RDS?

  • @lighninggamerz6571
    @lighninggamerz6571 4 месяца назад

    great explanation Maciej ..One thing I would like to know is using aws-secretsmanager-jdbc library if the application is using old password and now if secrets rotation happens how application works without restarting it ? I mean how application establishes the connection with new password without restarting ?

  • @bbNganNguyen
    @bbNganNguyen 4 года назад

    I follow the instruction but I dont know why my DB's password is not encrypt and it's still show the plain text. For example your password is myscecret and after creating the key, it's still show myscecret. Can you give me the advise?

  • @TheRealDoubleT
    @TheRealDoubleT 4 года назад

    Do you need the client id and the client secret as environment variables in order for this to work?

    • @SpringAcademy
      @SpringAcademy  4 года назад

      When you run it on EC2 once you get IAM policies right it will work. On local you should ideally have AWS SDK configured.

  • @sangitabiswas352
    @sangitabiswas352 Год назад

    Amy idea how to handle this same scenario in NodeJs?

  • @salapati72
    @salapati72 4 года назад

    i am using aurora postgresql and its not working. does the url change when i switch to the secrets manager (not the prefix, the host part or port part i mean)? also, my db is in a private subnet. i dont have to change any roles, policies, security groups right? thanks.

    • @SpringAcademy
      @SpringAcademy  4 года назад

      I haven't tried it with Aurora but I believe it should work

  • @ansariamin3865
    @ansariamin3865 Год назад

    Guyz I am trying to integrate the secret Manager on on premise web server…. We have jboss eap which is connecting to cloud database now I want to mask the id and password using secret manager on the on prem server… have tried multiple method online but nothing seems to work ……does anyone have document for this will by much help

  • @guchelkaben523
    @guchelkaben523 4 года назад

    How it works with amazon documentdb?

  • @fatossopjani2826
    @fatossopjani2826 3 года назад

    Is there a way using this dependency to make the data source url dynamic, including the port number?

    • @bajranglal4475
      @bajranglal4475 2 года назад

      I am also looking how we can read host port from same secretsmanager..instead of hadcoding

  • @nikhilraj3705
    @nikhilraj3705 4 года назад

    Sir,
    Please suggest me subjects to become full stack java developer and best Datastructure course.
    Thanks in advance.

  • @shekhshek3200
    @shekhshek3200 4 года назад +1

    This approach works fine for spring data source using jdbc template but not working with spring boot jpa applications.Any idea??
    Error:
    ERROR o.s.boot.SpringApplication.reportFailure - Application run failed
    org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'entityManagerFactory' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaConfiguration.class]: Unsatisfied dependency expressed through method 'entityManagerFactory' parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'entityManagerFactoryBuilder' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaConfiguration.class]: Unsatisfied dependency expressed through method 'entityManagerFactoryBuilder' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'jpaVendorAdapter' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.orm.jpa.JpaVendorAdapter]: Factory method 'jpaVendorAdapter' threw exception; nested exception is java.lang.RuntimeException: Driver com.mysql.cj.jdbc.Driver claims to not accept jdbcUrl, jdbc-secretsmanager:mysql://hostname:3306/dbname

    • @hugowong9871
      @hugowong9871 4 месяца назад

      If you are using AWS Academy, you need to update the credentials located in ~/.aws/credentials to the latest one

  • @genthoxha4162
    @genthoxha4162 4 года назад

    Failed to initialize pool: Invalid name. Must be a valid name containing alphanumeric characters, or any of the following: -/_+=.@! ...
    Any idea how can fix this?

  • @khoale8688
    @khoale8688 2 года назад +1

    Thanks for the video. One question, do we have any way to hide the real url of database such like username and password. Anyway thank you your video to get me an idea for this situation.

    • @SpringAcademy
      @SpringAcademy  2 года назад

      And use instance or cluster Id instead of passing URL? This is likely doable but not trivial

  • @dominikbartholdi9444
    @dominikbartholdi9444 5 лет назад +1

    I might have missed something, but why did your local application have permission to access the secretmanager? kind of looks like everyone could get your passwords from the secret manager.

    • @SpringAcademy
      @SpringAcademy  5 лет назад +2

      I have AWS CLI set up on my localhost so you would need to have access key and secret set up to access password manager. Anyway this is not the setup you should have for real world application - it's a shortcut I took similar to having public access to the database to focus in this video on things that matter the most.

  • @shaivaljava401
    @shaivaljava401 3 года назад

    Reason: Unable to find a region via the region provider chain. Must provide an explicit region in the builder or setup environment to supply a region.
    getting this error. please advise.

    • @SpringAcademy
      @SpringAcademy  3 года назад

      I guess it happens when you run on localhost? Make sure to configure AWS CLI

  • @subodhgholap
    @subodhgholap 6 месяцев назад

    Hello, Can you please share your example repo (spring-boot-secrets-manager-jdbc-demo) with us ? Thank you for gr8 session

  • @vasaviguntamukkala1867
    @vasaviguntamukkala1867 2 года назад +1

    Anyone help me instead of Spring boot i need to use node js any idea about this.
    Thanks :)

    • @SpringAcademy
      @SpringAcademy  2 года назад

      With NodeJS you can always use just the AWS SDK for Javascript.

  • @mame-techmore8000
    @mame-techmore8000 4 года назад

    What about documentDB=

  • @olehstepaniak2775
    @olehstepaniak2775 3 года назад

    Hi, one more time. How we can rotate DB password using AWS SM, but at our local DB - not from the RDS list? For example, I would back to REDIS. We have Redis(we haven't Redis engine in AWS RDS), and we need to change a password for him every month(It's would be nice if you send some tutorials how we can change this value programicaly). This is my poc, but I really want to know how to provide the secret to DB , which we haven't in RDS variability(or have, but we don't want to use RDS). (mb, we need a specific configuration?)
    And thx for your great work. Your channel is really helpful. Better on RUclips.

    • @SpringAcademy
      @SpringAcademy  3 года назад +1

      I didn't work with password rotation in redis. I think this may be useful for you aws.amazon.com/about-aws/whats-new/2019/10/amazon-elasticache-announces-support-for-modifying-redis-authentication-tokens/

    • @olehstepaniak2775
      @olehstepaniak2775 3 года назад

      @@SpringAcademy Thx for your fast response, no info about Redis pass rotation in net and that is soo sad. Because very often we need to save data storage in production using pass rotation. And if RDS engines have simple API - we cant talk in this way about NoSQL API's.

  • @dhruvsingh6044
    @dhruvsingh6044 Год назад

    Can you please provide me this application code for testing, Please share github link for the same code?

  • @Parthp1045
    @Parthp1045 21 день назад

    Any one know how to do in python using fast api?

  • @arunmathew5982
    @arunmathew5982 4 года назад

    Hi Thanks for a wonderful tuitorial, I am getting an error on spring.datasource.driver-class-name=com.amazonaws.secretsmanager.sql.AWSSecretsManagerPostgreSQLDriver
    Error is :
    Failed to bind properties under '' to com.zaxxer.hikari.HikariDataSource:
    Property: driver-class-name
    Value: com.amazonaws.secretsmanager.sql.AWSSecretsManagerPostgreSQLDriver
    Origin: "driverClassName" from property source "source"
    Reason: Unable to find a region via the region provider chain. Must provide an explicit region in the builder or setup environment to supply a region.
    Current Property file entries are :
    spring.datasource.url=jdbc-secretsmanager:postgresql://database-2.cvsjlkvjytkt.us-east-2.rds.amazonaws.com/postgres
    spring.datasource.driver-class-name=com.amazonaws.secretsmanager.sql.AWSSecretsManagerPostgreSQLDriver
    spring.datasource.username=/secrets/my-app/db
    Can you please help on this issue

    • @SpringAcademy
      @SpringAcademy  4 года назад

      Hey Arun! Are you getting this when running locally or on AWS environment? If locally, you need to have AWS CLI Set up, meaning in ~.awc/credentials have properties for secret key, access key and region.

    • @arunmathew5982
      @arunmathew5982 4 года назад

      Hi @@SpringAcademy I was trying to run locally. Thaks for a valuable information.

    • @destroyerhunt3959
      @destroyerhunt3959 2 года назад

      @Spring Academy - if I want to run it on local system, can you suggest a way to setup region explicitly if possible to fix this problem

  • @marcellodimarinoazevedo
    @marcellodimarinoazevedo 4 года назад

    Great, give an application FULL grants over RDS... Bad idea.