Skip to content
This repository has been archived by the owner on Oct 6, 2022. It is now read-only.

support secret parameter for ecs task definitinon with Fargate #7

Closed
pahud opened this issue May 25, 2020 · 6 comments · Fixed by #21
Closed

support secret parameter for ecs task definitinon with Fargate #7

pahud opened this issue May 25, 2020 · 6 comments · Fixed by #21

Comments

@pahud
Copy link
Contributor

pahud commented May 25, 2020

'AURORA_MASTER_PASSWORD': ecs.Secret.fromSecretsManager(auroraMasterSecret),
'RADMIN_PASSWORD': ecs.Secret.fromSecretsManager(radminSecret),

It is only supported to inject the full contents of a secret as an environment variable. Specifying a specific JSON key or version is not supported at this time.
https://docs.aws.amazon.com/AmazonECS/latest/developerguide/specifying-sensitive-data-secrets.html

depends on aws/containers-roadmap#385

@snese
Copy link

snese commented Nov 11, 2020

@pahud The issue aws/containers-roadmap#385 had closed, let's move on to next stage, lol

@DanyC97
Copy link

DanyC97 commented Jan 6, 2021

in case i haven't misunderstood the issue, i think the code is present as far as i can see and can confirm in the generated CFN templates that it does what is supposed to do

ProxySQLTask66A1033A:
    Type: AWS::ECS::TaskDefinition
    Properties:
      ContainerDefinitions:
        - Environment:
            - Name: DB_WRITER_HOSTNAME
              Value: writer.proxysql.local
            - Name: DB_READER_HOSTNAME
              Value: reader.proxysql.local
            - Name: DB_WRITER_PORT
              Value: '3306'
            - Name: DB_READER_PORT
              Value: '3306'
            - Name: DB_MASTER_USERNAME
              Value: admin
          Essential: true
          Image: !Join
            - ''
            - - 12345.dkr.ecr.us-east-1.
              - !Ref 'AWS::URLSuffix'
              - /aws-cdk/assets:0a48c0d6e2f688ca9f4b45efafa4dc5b6955193dc045a30b5f73131013ed3a6a
          LogConfiguration:
            LogDriver: awslogs
            Options:
              awslogs-group: !Ref 'ProxySQLTaskproxysqlLogGroup48D393F6'
              awslogs-stream-prefix: proxysql-main
              awslogs-region: us-east-1
          Name: proxysql
          PortMappings:
            - ContainerPort: 6033
              Protocol: tcp
            - ContainerPort: 6032
              Protocol: tcp
          Secrets:
            - Name: DB_MASTER_PASSWORD
              ValueFrom: !Ref 'ProxySQLAuroraMasterSecret65F602CE'
            - Name: RADMIN_PASSWORD
              ValueFrom: !Ref 'ProxySQLRAdminPassword14486454'

....

  ProxySQLAuroraMasterSecret65F602CE:
    Type: AWS::SecretsManager::Secret
    Properties:
      GenerateSecretString:
        ExcludePunctuation: true
        PasswordLength: 12
      Name: ProxysqlFargateStack-auroraMasterSecret
    Metadata:
      aws:cdk:path: ProxysqlFargateStack/ProxySQL/AuroraMasterSecret/Resource
  ProxySQLRAdminPassword14486454:
    Type: AWS::SecretsManager::Secret
    Properties:
      GenerateSecretString:
        ExcludePunctuation: true
        PasswordLength: 12
      Name: ProxysqlFargateStack-radmin_pwd
    Metadata:
      aws:cdk:path: ProxysqlFargateStack/ProxySQL/RAdminPassword/Resource

Hence i think it can be closed?

Edit

And if what i wrote above is correct then the readme can be udpated & remove the stale section

@pahud
Copy link
Contributor Author

pahud commented Jan 7, 2021

@DanyC97 thank you for your feedback.

Let me know if you have any issues and any PRs are always welcome!

@DanyC97
Copy link

DanyC97 commented Jan 7, 2021

thank you @pahud for coming back to us, much appreciated !

And if what i wrote above is correct then the readme can be udpated & remove the stale section

is my understanding correct that the above readme section can be removed or i've got it wrong ?

@pahud
Copy link
Contributor Author

pahud commented Jan 7, 2021

@DanyC97 Yes I have removed the stale section already at #21

Did I miss anything?

@DanyC97
Copy link

DanyC97 commented Jan 7, 2021

@pahud on a double check, is me who misunderstood.

In my link i pointed out to which is a different feature 🤦


Custom master password Secret

Use masterSecret to specify your master password from existing Secret.

const const YOUR_SECRET_ARN = 'arn:aws:secretsmanager:ap-northeast-1:112233445566:secret:xxxxxxx-rC5RTf'
const masterSecret = secretsmanager.Secret.fromSecretArn(stack, 'Secret', YOUR_SECRET_ARN)
new proxysql.ProxysqlFargate(stack, 'ProxySQL', {
  vpc: infra.vpc,
  customBackend: {
    readerHost: 'foo',
    writerHost: 'bar',
    masterSecret,
  }
})

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants