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

aws-lambda-tools-defaults.json documentation #54

Closed
patoncrispy opened this issue Jan 17, 2019 · 9 comments
Closed

aws-lambda-tools-defaults.json documentation #54

patoncrispy opened this issue Jan 17, 2019 · 9 comments
Labels
closing-soon This issue will automatically close in 4 days unless further comments are made. documentation This is a problem with documentation. guidance Question that needs advice or information. module/cli-ext

Comments

@patoncrispy
Copy link

Is there documentation for aws-lambda-tools-defaults.json somewhere? I've been Googling it and can't find anything. Only by sheer luck did I stumble across the template-substitutions property in an example and it would have come in handy a looong time ago. It would be great to see what other value I'm missing out on.

Also, is it possible to define multiple template-substitutions? I tried using an array of strings but it doesn't seem to work.

Thanks!

@klaytaybai klaytaybai added investigating This issue is being investigated and/or work is in progress to resolve the issue. documentation This is a problem with documentation. guidance Question that needs advice or information. and removed investigating This issue is being investigated and/or work is in progress to resolve the issue. labels Jan 21, 2019
@klaytaybai
Copy link

Hi @patoncrispy, I'm not aware of any more documentation either. I think the best advice I could give you would be to look at the relevant code in our repository when you wish to use the defaults file. This will also ensure that you are using a current source for your information.

Helpful files:
This will show you what you can use in the aws-lambda-tools-defaults.json file.
https://github.com/aws/aws-extensions-for-dotnet-cli/blob/master/src/Amazon.Lambda.Tools/LambdaToolsDefaults.cs

These will show you the information for the options you can use.
https://github.com/aws/aws-extensions-for-dotnet-cli/blob/master/src/Amazon.Lambda.Tools/LambdaDefinedCommandOptions.cs

https://github.com/aws/aws-extensions-for-dotnet-cli/blob/master/src/Amazon.Common.DotNetCli.Tools/Options/CommonDefinedCommandOptions.cs

@klaytaybai klaytaybai added the closing-soon This issue will automatically close in 4 days unless further comments are made. label Jan 21, 2019
@normj
Copy link
Member

normj commented Jan 21, 2019

I agree this file could use some documentation but there is not much to it. The file is a short cut for setting parameters on the commandline. For example if you execute dotnet lambda deploy-serverless --help you will see template-substitutions in the help:

normj@SEA-9903672753 C:\codebase\aws-extensions-for-dotnet-cli\test\Amazon.Lambda.Tools.Test
> dotnet lambda deploy-serverless --help
Amazon Lambda Tools for .NET Core applications (3.1.2)
Project Home: https://github.com/aws/aws-extensions-for-dotnet-cli, https://github.com/aws/aws-lambda-dotnet

deploy-serverless:
   Command to deploy an AWS Serverless application

   dotnet lambda deploy-serverless [arguments] [options]
   Arguments:
      <STACK-NAME> The name of the CloudFormation stack used to deploy the AWS Serverless application
   Options:
      --disable-interactive                   When set to true missing required parameters will not be prompted for.
      --region                                The region to connect to AWS services, if not set region will be detected from the environment.
      --profile                               Profile to use to look up AWS credentials, if not set environment credentials will be used.
      --profile-location                      Optional override to the search location for Profiles, points at a shared credentials file.
      --aws-access-key-id                     The AWS access key id. Used when setting credentials explicitly instead of using --profile.
      --aws-secret-key                        The AWS secret key. Used when setting credentials explicitly instead of using --profile.
      --aws-session-token                     The AWS session token. Used when setting credentials explicitly instead of using --profile.
      -pl    | --project-location             The location of the project, if not set the current directory will be assumed.
      -cfg   | --config-file                  Configuration file storing default values for command line arguments.
      -pcfg  | --persist-config-file          If true the arguments used for a successful deployment are persisted to a config file.
      -c     | --configuration                Configuration to build with, for example Release or Debug.
      -f     | --framework                    Target framework to compile, for example netcoreapp2.1.
      --msbuild-parameters                    Additional msbuild parameters passed to the 'dotnet publish' command. Add quotes around the value if the value contains spaces.
      -pac   | --package                      Application package to use for deployment, skips building the project
      -sb    | --s3-bucket                    S3 bucket to upload the build output
      -sp    | --s3-prefix                    S3 prefix for for the build output
      -t     | --template                     Path to the CloudFormation template
      -tp    | --template-parameters          CloudFormation template parameters. Format is <key1>=<value1>;<key2>=<value2>
      -ts    | --template-substitutions       JSON based CloudFormation template substitutions. Format is <JSONPath>=<Substitution>;<JSONPath>=...
      -cfrole | --cloudformation-role         Optional role that CloudFormation assumes when creating or updated CloudFormation stack.
      -sn    | --stack-name                   CloudFormation stack name for an AWS Serverless application
      -dc    | --disable-capabilities         Comma delimited list of capabilities to disable when creating a CloudFormation Stack.
      --tags                                  AWS tags to apply. Format is <name1>=<value1>;<name2>=<value2>
      -sw    | --stack-wait                   If true wait for the Stack to finish updating before exiting. Default is true.
      -dvc   | --disable-version-check        Disable the .NET Core version check. Only for advanced usage.

All these fields can be set in aws-lambda-tools-defaults.json minus the -- and then when you deploy it will pick up the files from this file that aren't set on the commandline. There is currently nothing in this file that can't be set on the command line.

@patoncrispy
Copy link
Author

Yeah I've been scanning through the source code alright. Managed to find a few useful things (template-substitutions). Having this information surfaced somewhere though would let newcomers know the extent of the capabilities the tooling has.

@yasinkavakliat
Copy link

Thank you @normj
Could have thought by myself but this was really helpful. 👍

@mungojam
Copy link

mungojam commented Mar 5, 2020

Documentation, or expanded information in the help text would be useful. There were two particular aspects that I didn't know until reading the comments in this issue:

  1. That it was a json file. I assumed it might just be a text file with the parameters verbatim
  2. The existence of a default file aws-lambda-tools-defaults.json so I didn't have to specify the name of the config file myself.

@benmccallum
Copy link

benmccallum commented Mar 26, 2020

@normj, could you provide an example of setting the runtime via the ms-build-parameters property of a aws-lambda-tools-defaults.json? I know it says "Add quotes around the value if the value contains spaces.", but is that for the whole thing or the value of the argument?

I've tried:

  • "msbuild-parameters": "-r rhel.7.2-x64" (reads switch as rhel.7.2-x64)
  • "msbuild-parameters": "\"-r rhel.7.2-x64\"" seems to read it better, but gives me :
publish: MSBUILD : error MSB1001: Unknown switch.
... publish: Switch: -r rhel.7.2-x64
... publish: For switch syntax, type "MSBuild -help"
  • "msbuild-parameters": "\"--runtime \"rhel.7.2-x64\"\"" gives the same as above (with --runtime obv).

I'm looking at the code, and I can't for the life of me figure out why that wouldn't work...

Update:
I got "msbuild-parameters" : "/p:RuntimeIdentifiers=rhel.7.2-x64" to work, but, ugh. Help on above would be great.

Update 2: Hmm, I think I thought it was working, but really it was doing nothing.

Update 3:
I'm apparently having to do this as the publish to aws menu option fails to build all of a sudden and let me publish. The dotnet SDK is saying the runtime (RID) should be specified. In the csproj works, but then all the deps are throwing warnings. I don't really want to have to do that though. Weirdly it stopped happening though and now I can, I think after I did a dotnet restore from cmdline. Really confusing; could be a VS bug.

@dalton5
Copy link

dalton5 commented Jul 26, 2020

Hi,

Is it possible to add the environement variable for the environement of development?

In fact, VS allows to setup appsettings.json, appsettings.testing.json, appsettings.json.production

It would be great to be able to rpovide environement varibel for the deployment of the lambda functions and automatically picking the good connection string .

Thanks,

@paul-michalik
Copy link

paul-michalik commented May 10, 2022

@benmccallum and others:

Has anyone figured out how to use msbuild-parameters property? In connection with a yaml template using AWS SAM how is this supposed to work? SAM obviously sets some MSBuild parameters already, can I override or add my own? I would like to control the temporary location for binaries, i.e. the value of the --output property to dotnet publish.

@normj
Copy link
Member

normj commented May 10, 2022

@paul-michalik I just created this feature request in our repo on what we should do to support this feature. I would appreciate your thoughts on if it would solve your needs. #213

It would also be best to move the discussion to an open issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
closing-soon This issue will automatically close in 4 days unless further comments are made. documentation This is a problem with documentation. guidance Question that needs advice or information. module/cli-ext
Projects
None yet
Development

No branches or pull requests

9 participants