binxio/cfn-secret-provider

Return Value "Name" for a keypair

Closed this issue · 22 comments

Hi, how can I get the Return Value "Name" for a keypair. merci A

@aerioeus Which Name are you looking for? The Name of the user is passed in. The returned AccessKey can be used as a username with login on SMTP.

I am looking for the resource name, like the keypair name. When I try !Ref Keypair it returns the ARN. but for many uses like ECS I need the pure Keypair name. Right now I use the !split function to get the KeyName from the ARN.

So, you actually looking to get the Name you provided as input parameter as output parameter. Right?

Version 0.12.3 has the functionality you requested.

Merci, what returns the Name? Did you change the !Ref output or do I need to use !GetAtt resource.name?

merci

sorry, doesnt seem to work,

I'm using:

  ECSKeyPair:
    Type: Custom::KeyPair
    DependsOn: CustomPrivateKey
    Properties:
      Name: ECSKeyPair
      PublicKeyMaterial:
        Fn::GetAtt:
        - CustomPrivateKey
        - PublicKey
      ServiceToken:
        Fn::Join:
        - ":"
        - - arn:aws:lambda
          - Ref: AWS::Region
          - Ref: AWS::AccountId
          - function:binxio-cfn-secret-provider


ECSKeyPairName:
Value: !GetAtt 'ECSKeyPair.name'
Description: ECSKeyPairName

and I'm getting the following error:

CustomResource attribute error: Vendor response doesn't contain name key in object arn:aws:cloudformation:eu-west-1:300746241447:stack/iam-stack-UserGroups-G5K80XQS8UMJ/4c970710-bb64-11e8-b88a-503ac9eaaa99|ECSKeyPair|086b41a6-afb3-4191-bef0-8ebb79e29914 in S3 bucket cloudformation-custom-resource-storage-euwest1

merci, typo, :-)

the Custom::Secret allows you to generate values in the SSM parameter store of type SecureString. It also allows you to store a value, but imho this defeats the purpose as your secret will need to be passed in.

PS: I would suggest to write:

        Fn::Join:
        - ":"
        - - arn:aws:lambda
          - Ref: AWS::Region
          - Ref: AWS::AccountId
          - function:binxio-cfn-secret-provider

as

      !Sub 'arn:aws:lambda:${AWS::Region}:${AWS::AccountId}:function:binxio-cfn-secret-provider'

Which is shorter and sweeter...

ok, let me have a look , that would be great, since calling the ssm-secure is supported by AWS since August, just creating one doesnt work (yet)

it seems there is an error in the yaml file, when I try to convert it I get: Error: SyntaxError: Unexpected token S in JSON at position 63

Merci, figured it out myself and tested it, works great, many thanks!!!

Hi, another question: How can I add a Description to the Secure Parameter?

i'm sorry to have to bother you again, but it doesnt work with the !GetAtt 'ECSKeyPair.Name'.
the error is still : CustomResource attribute error: Vendor response doesn't contain Name key in object arn:aws:cloudformation:eu

when I try Value: !Select [1, !Split ["/", !Ref ECSKeyPair]] everything works fine; I have repeatedly updated the repository, so I dont know how to fix that..

another question; is it actually possible to generate multiple keypairs with this provider or is it limited to just one?

Hi, another question: How can I add a Description to the Secure Parameter?

Yes. Just specify the Description property.

another question; is it actually possible to generate multiple keypairs with this provider or is it limited to just one?

Yes you can. Just you other key names...

i'm sorry to have to bother you again, but it doesnt work with the !GetAtt 'ECSKeyPair.Name'.

Did you deploy the latest vesion of the cfn-secret-provider into your account and created the keypair with it?