Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extend template-parameter definition syntax in serverless configuration file #258

Open
1 of 2 tasks
jasonterando opened this issue Dec 18, 2022 · 1 comment
Open
1 of 2 tasks
Labels
feature-request A feature should be added or improved. module/cli-ext p2 This is a standard priority issue queued

Comments

@jasonterando
Copy link

jasonterando commented Dec 18, 2022

Describe the feature

Extend supported syntax for defining "template-parameters" in serverless template configuration JSON files to include object and array syntax.

Use Case

If deploying a serverless template with a lot of parameters, the format "key1=value1;key2=value2;...keyN=valueN" becomes difficult to manage, especially if you are creating multiple configuration to support different environments (ex. Q/A, staging, production).

Proposed Solution

Update AmazonLambdaTools to check the parameter type for template-parameters.

  • [Current] If it's a string, generate a Dictionary using current syntax ("key1=value1;key2=value2;...keyN=valueN")
  • [New] If it's an object, process it using property names for keys and cast values as string
  • [New] If it's an array of strings, process it using the syntax supported by SAM, which s a list of "key=value" strings

This approach is backward compatible, it won't break usage of existing template files.

Current Format (string)

{
    "template-parameters": "Secret1ARN=arn:aws:secretsmanager:us-west-1:999888777666:secret:db.mysecret3-AbCdEf;Secret2ARN=arn:aws:secretsmanager:us-west-1:999888777666:secret:mysecret2-GhIkJl;DNSName=leads-aot;AspNetCoreEnvironment=qa;Stage=live;DNSDomain=my-domain.net;HostedZoneId=Z001329499ABC;CertificateArn=arn:aws:acm:us-west-1:999888777666:certificate/111111-aa-2222-cccc-9999999999999;UserPoolId=us-west-1_YzYzYzYzYz;CognitoUserPoolArn=arn:aws:cognito-idp:us-west-1:999888777666:userpool/us-west-1_YzYzYzYzYz;VpcEndpointId=vpce-02e2c2b9db2c3b9f6;LoadBalancerDns=private-my-domain-net-lb-c12345d987654.elb.us-west-1.amazonaws.com;VpcSubnetIds=subnet-111111,subnet-222222;VpcSecurityGroupIds=sg-00011122233334444"
}

New Format (object)

    "template-parameters": {
        "Secret1ARN": "arn:aws:secretsmanager:us-west-1:999888777666:secret:db.mysecret3-AbCdEf",
        "Secret2ARN": "arn:aws:secretsmanager:us-west-1:999888777666:secret:mysecret2-GhIkJl",
        "DNSName": "leads-aot",
        "AspNetCoreEnvironment": "qa",
        "Stage": "live",
        "DNSDomain": "my-domain.net",
        "HostedZoneId": "Z001329499ABC",
        "CertificateArn": "arn:aws:acm:us-west-1:999888777666:certificate/111111-aa-2222-cccc-9999999999999",
        "UserPoolId": "us-west-1_YzYzYzYzYz",
        "CognitoUserPoolArn": "arn:aws:cognito-idp:us-west-1:999888777666:userpool/us-west-1_YzYzYzYzYz",
        "VpcEndpointId": "vpce-02e2c2b9db2c3b9f6",
        "LoadBalancerDns": "private-my-domain-net-lb-c12345d987654.elb.us-west-1.amazonaws.com",
        "VpcSubnetIds": "subnet-111111,subnet-222222",
        "VpcSecurityGroupIds": "sg-00011122233334444"
    },

New Format (array - SAM compatible)

{
    "template-parameters": [
        "Secret1ARN=arn:aws:secretsmanager:us-west-1:999888777666:secret:db.mysecret3-AbCdEf",
        "Secret2ARN=arn:aws:secretsmanager:us-west-1:999888777666:secret:mysecret2-GhIkJl",
        "DNSName=leads-aot",
        "AspNetCoreEnvironment=qa",
        "Stage=live",
        "DNSDomain=my-domain.net",
        "HostedZoneId=Z001329499ABC",
        "CertificateArn=arn:aws:acm:us-west-1:999888777666:certificate/111111-aa-2222-cccc-9999999999999",
        "UserPoolId=us-west-1_YzYzYzYzYz",
        "CognitoUserPoolArn=arn:aws:cognito-idp:us-west-1:999888777666:userpool/us-west-1_YzYzYzYzYz",
        "VpcEndpointId=vpce-02e2c2b9db2c3b9f6",
        "LoadBalancerDns=private-my-domain-net-lb-c12345d987654.elb.us-west-1.amazonaws.com",
        "VpcSubnetIds=subnet-111111,subnet-222222",
        "VpcSecurityGroupIds=sg-00011122233334444"
    ]
}

Other Information

I'll be submitting a PR implementing this change

Acknowledgements

  • I may be able to implement this feature request
  • This feature might incur a breaking change

Targeted .NET platform

(All)

CLI extension version

No response

Environment details (OS name and version, etc.)

Any

@jasonterando jasonterando added feature-request A feature should be added or improved. needs-triage This issue or PR still needs to be triaged. labels Dec 18, 2022
@jasonterando jasonterando changed the title Extend template-parameter definition syntax in serverless template Extend template-parameter definition syntax in serverless configuration file Dec 18, 2022
@ashishdhingra ashishdhingra added module/cli-ext pr/needs-review This PR needs a review from a Member. labels Dec 19, 2022
@ashishdhingra
Copy link
Contributor

Needs review with the team. Customer has proposed a PR.

@ashishdhingra ashishdhingra added needs-review p2 This is a standard priority issue and removed needs-triage This issue or PR still needs to be triaged. labels Dec 27, 2022
@ashishdhingra ashishdhingra removed the pr/needs-review This PR needs a review from a Member. label Jul 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-request A feature should be added or improved. module/cli-ext p2 This is a standard priority issue queued
Projects
None yet
Development

No branches or pull requests

2 participants