Open Bilboramix opened 4 months ago
HI @Bilboramix - thank you for reaching out and sorry to hear you're seeing the error.
It looks like you're following documentation from different client @aws-sdk/client-location. Here's KMS docs you need for your use case. I understand that it's because some AWS services have operation commands in common and sometimes you might have to double check you're looking at the client you need.
This's also a good feedback for us to improve our documentations to be more user-friendly. Here's code example to create key with KMS:
import { KMSClient, CreateKeyCommand } from "@aws-sdk/client-kms"; // ES Modules import
const client = new KMSClient(config);
const input = { // CreateKeyRequest
Policy: "STRING_VALUE",
Description: "STRING_VALUE",
KeyUsage: "SIGN_VERIFY",
CustomerMasterKeySpec: "RSA_2048",
KeySpec: "RSA_2048",
Origin: "AWS_KMS",
CustomKeyStoreId: "STRING_VALUE",
BypassPolicyLockoutSafetyCheck: true || false,
Tags: [ // TagList
{ // Tag
TagKey: "STRING_VALUE", // required
TagValue: "STRING_VALUE", // required
},
],
MultiRegion: true,
XksKeyId: "STRING_VALUE",
};
const command = new CreateKeyCommand(input);
const response = await client.send(command);
You can also refer to the documentation from KMS service itself.
Hope it helps, John
Oh okay, AWS tools are new to me and i obviously did not noticed i was not reading the right documentation... When i did my research i just typed "CreateKeyCommand" in google then i found this doc on the first link. The good one was just below.. Sorry for that !
Still, i can see that there's no property to explictly name the CMK so it will stay unnamed for now. It's not blocking me at all. Just that if we could put some value in this field trough the API as we can do it trough user interface, it would be great.
Essentialy for testing purposes : While i'm making my system i can more easily differenciate my keys if it's named instead of looking to the guids. But that's fine too.
Thanks a lot for your help !
No worries, happy to help. As I mentioned, we'll use this feedback to improve our docs to be more user-friendly to first-time users like you.
Still, i can see that there's no property to explictly name the CMK so it will stay unnamed for now. It's not blocking me at all. Just that if we could put some value in this field trough the API as we can do it trough user interface, it would be great.
I didn't quite understand this line here, can you please elaborate more on "there's no property to explictly name the CMK so it will stay unnamed for now"? I understand it's not a blocker for you but I'd be happy to clarify that for you if you'd like.
On the kms web form we got a field named "Alias" (my bad, it was not "Key name") to explictly name the CMK right here :
But we do not have this field mentionned in the 2 docs that describe the CreateKey api : Taken from here : https://docs.aws.amazon.com/kms/latest/APIReference/API_CreateKey.html
And this one : Taken from here : https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/client/kms/command/CreateKeyCommand/
Here you can see that i created the "testrotate" key trough the web form, the others are created trough the api :
I guess this is a wanted behavior as we're not supposed to rely on the name to make any action (right now, i'm using key's ARN). Not sure if adding an "Alias" field to CreateCommand keys would be worth it but this would unify the web form and the api (this is the only field we cannot set by code). Also, I tried to force the "KeyName" field despite the typescript error (and it did not worked as i said above). But i did not tried to force with an "Alias" field. Maybe it's just not documented and actually working.
Describe the issue
Hello there, in the doc there's an option "KeyName" that should be given to CreateKeyCommand constructor. Unfortunatly i've got this typescript error :
For this code snippet :
Running the script anyway I can see on the KMS dashboard that the parameter is not consumed by the api as well (Name value at first column is undefined and displayed with "-") :
Maybe the doc is not up to date and this parameter changed ? I cannot see this parameter anywhere into the example provided in types declarations files but it's there in the doc.
If someone has any workaround to address this issue i'll take it as well.
Thanks for investigating, regards, Bill.
Links
https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/client/location/command/CreateKeyCommand/