'Unable to fetch secrets using Instance Profile from databricks for a spring boot application

I am using spring-cloud-starter-aws-secrets-manager-config 2.3.3 for a spring boot application which works perfectly in my local pointing to stage environment where i configure AWS_PROFILE to fetch secrets.

spring.config.import=aws-secretsmanager:service/xyz/stage-v2/email/smtp;
service/xyz/stage-v2/ex/db/token

    <dependency>
        <groupId>io.awspring.cloud</groupId>
        <artifactId>spring-cloud-starter-aws-secrets-manager-config</artifactId>
        <version>2.3.3</version>
    </dependency>

In stage environment i am setting up instance profile and a assume role profile.

with the same role setup other applications run but they are not spring based.

but application fails to fetch secret values with below error :

Config data resource '[AwsSecretsManagerConfigDataResource@71560f51 context = 'service/xyz/stage-v2/ex/db/token', optional = false]' via location 'aws-secretsmanager:service/xyz/stage-v2/email/smtp;service/xyz/stage-v2/ex/db/token' does not exist

I am configuring an instance profile in databricks which does not have access to my secrets.But it is allowed another assume role which has access.

Recently upon debugging i found that spring application is trying to access aws with instance profile account Id instead of the assumedRole.

So i just need to know how do we pass the assumableRole to spring boot app.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source