5

Having ResourceNotFoundException when using secrets ARN

Tried getting secret only using secret name - doesn't work. Tried getting secret using ARN - doesn't work. I've checked my assumed role's policy and SM is set as far as I understand like this in the JSON format "secretsmanager:*"

The command I'm using in a CloudBees job is this:

aws secretsmanager get-secret-value --secret-id <ARN>

Not sure what is the issue at the moment. All help appreciated!

Dave

N3R4ZZuRR0
  • 2,400
  • 4
  • 18
  • 32
David Barth
  • 59
  • 1
  • 1
  • 3

3 Answers3

11

There is not enough information here to tell for sure what the problem is. However, the command line you have does not specify a region and you may be defaulting to the wrong region. Pass --region REGION to the CLI (where REGION is the real region name; e.g. us-east-1) and make sure REGION is the same as the region in the ARN.

JoeB
  • 1,503
  • 7
  • 9
3

You may have a secret resource without any secret value configured

You can verify that the secret resource exists using -

aws secretsmanager describe-secret --secret-id <ARN or NAME>

Quoted from AWS CLI aws secretsmanager command documentation:

--secret-id (string)

The ARN or name of the secret to add a new version to.

For an ARN, we recommend that you specify a complete ARN rather than a partial ARN.

In case you receive the secret resource details you may need to set a secret value using the command:

aws secretsmanager put-secret-value --secret-id <ARN or NAME> --secret-string '[{"user":"username"},{"pass":"password"}]'

And after the secret resource value is set you should be able to use get-secret-value command

Eladio
  • 369
  • 1
  • 5
2

I ran into this one as well, my issue was the id was wrong.

aws secretsmanager get-secret-value --secret-id <ARN>

The ARN actually needed to be the secret name.