6

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

4 Answers 4

12

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.

Sign up to request clarification or add additional context in comments.

1 Comment

--region flag tripped me up. Unhelpful error message as per.
4

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

Comments

3

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.

Comments

0

I had the same issue when mocking Secretes Manager with https://github.com/getmoto/moto (MOTO) library.

Removing AWS_DEFAULT_REGION env variable solved my problem.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.