https://pulumi.com logo
Title
f

fresh-summer-65887

04/03/2021, 6:23 PM
Is it possible to set an aws provider's endpoints (
ProviderArgs.Endpoints
) via config yaml? Or do I have to new up
Provider
and set the Endpoints manually? (I've trawled the docs, can't find anything regarding this).
b

billowy-army-68599

04/03/2021, 6:29 PM
you can set it via
pulumi config set aws:endpoints
but it will then be global for all resources, is that what you want?
the yaml will be nested, so you might need to handwrite it
f

fresh-summer-65887

04/03/2021, 6:37 PM
Yes, that is what I want (it's a temporary local stack).
Yes I was trying to do this via the cli and automation API.
If it needs to be hand written and can't be done via CLI then it's safe to assume it won't work via automation API either.
(thanks for response btw)
b

billowy-army-68599

04/03/2021, 6:42 PM
I believe it can be done via automation API, but I'd need to figure out the right syntax for the config set commands. You'd use the ConfigMap option https://www.pulumi.com/docs/reference/pkg/nodejs/pulumi/pulumi/x/automation/#ConfigMap
f

fresh-summer-65887

04/03/2021, 6:46 PM
Yep am using the config map (.net version). Can't figure out the content/structure of the config value.
b

billowy-army-68599

04/03/2021, 6:48 PM
you're using localstack? just wanna make sure I'm recreating this accurately
❤️ 1
f

fresh-summer-65887

04/03/2021, 6:50 PM
dynamodb-local actualy
am exploring doing a local integration using the automation api to setup a fixture hoping to re-use the dynamodb pulumi resources in both the fixture and the real stack
I was going to try localstack next though I fully expect it to have bugs / flaws / gaps and generally be unsupported.
Here is my code so far, if it helps.
(I need to figure out better way than running the equivalent of "pulumi login --local" via automation api)
👍 1
My stack is simple
public class DefaultStack : Stack
    {
        public DefaultStack()
        {
            var tableArgs = new TableArgs
            {
                Name = "table",
                Attributes =
                {
                    new TableAttributeArgs
                    {
                        Name = "PK",
                        Type = "S",
                    },
                    new TableAttributeArgs
                    {
                        Name = "SK",
                        Type = "S",
                    }
                },
                HashKey = "PK",
                RangeKey = "SK",
                BillingMode = "PAY_PER_REQUEST",
            };

            new Table("table", tableArgs);
        }
    }
b

billowy-army-68599

04/03/2021, 7:02 PM
this is what I'd expect to work:
pulumi config set --path 'aws:endpoints[0].dynamodb' <http://localhost:4566>
but it doesn't, for whatever reason
pulumi config set --path 'aws:endpoints[0].dynamodb' <http://localhost:4566>
warning: A new version of Pulumi is available. To upgrade from version '2.23.2' to '2.24.1', visit <https://pulumi.com/docs/reference/install/> for manual instructions and release notes.
error: a map was expected for key "dynamodb"
f

fresh-summer-65887

04/03/2021, 7:06 PM
hmm
❯ pulumi config set --path '["aws:endpoints"]:["dynamodb"]' <http://example.com>
error: invalid configuration key: could not parse [aws:endpoints]:[dynamodb] as a configuration key (configuration keys should be of the form `<namespace>:<name>`)
Was attempting to follow this
b

billowy-army-68599

04/03/2021, 7:15 PM
pulumi config set --path 'aws:endpoints[0]["dynamodb"]' <http://example.com>
Seems to work
so I believe your code would be:
{"aws:endpoints[0]["dynamodb"], new ConfigValue("foo")}
f

fresh-summer-65887

04/03/2021, 7:29 PM
will give it a go
await _workspaceStack.SetConfigAsync(new Dictionary<string, ConfigValue>
            {
                {"aws:region", new ConfigValue("eu-west-1")},
                {"aws:accessKey", new ConfigValue("not")},
                {"aws:secretKey", new ConfigValue("used")},
                {"aws:endpoints[0][\"dynamodb\"]" , new ConfigValue("<http://example.com>")}
            });
... is what I'm using
had to tweak the it a bit with the quotes
results in this error:
Pulumi.Automation.Commands.Exceptions.CommandException: code: -1
stdout: Updating (testing):

 +  pulumi:pulumi:Stack dynamodb-tests-testing creating 
    aws:dynamodb:Table table  error: could not validate provider configuration: 1 error occurred:
 +  pulumi:pulumi:Stack dynamodb-tests-testing created 
    aws:dynamodb:Table table **failed** 1 error
 
Diagnostics:
  aws:dynamodb:Table (table):
    error: could not validate provider configuration: 1 error occurred:
    	* Invalid or unknown key
 
Resources:
    + 1 created
what does the cli look like that works for you?
b

billowy-army-68599

04/03/2021, 8:03 PM
config:
  aws:endpoints:
  - dynamodb: <http://example.com>
  aws:region: us-west-2
f

fresh-summer-65887

04/03/2021, 8:11 PM
That's the result, what was the command? 🙂
b

billowy-army-68599

04/03/2021, 8:12 PM
pulumi config set --path 'aws:endpoints[0]["dynamodb"]' <http://example.com>
f

fresh-summer-65887

04/03/2021, 8:14 PM
Worked on bash, gonna see what it looks like on powershell...
pulumi config set --path "aws:endpoints[0][""dynamodb""]" <http://example.com>
pulumi config set --path "aws:endpoints[0]['dynamodb']" <http://example.com>
pulumi config set --path "aws:endpoints[0][\"dynamodb\"]" <http://example.com>
none of the above worked...
b

billowy-army-68599

04/03/2021, 8:24 PM
it shouldn't be this hard, I know that much. I'm going to file an issue on Monday
👍 1
f

fresh-summer-65887

04/03/2021, 8:24 PM
pulumi config set --path 'aws:endpoints[0][\"dynamodb\"]' <http://example.com>
worked.
This doesn't work on automation API. I don't see the
--path
equivalent here.
b

billowy-army-68599

04/03/2021, 8:31 PM
f

fresh-summer-65887

04/03/2021, 8:36 PM
There's no ConfigMap type on the .net api. There is a
configMap
parameter that is a dictionary which is what I'm using.
b

billowy-army-68599

04/03/2021, 8:38 PM
fun! Would you mind opening an issue around this experience? we need to make this better
f

fresh-summer-65887

04/03/2021, 8:39 PM
will do 🙂
Prob in the morning, late now. Hacking fatigue kicking in 🙂
Thanks for the engagement Lee.
Created the issue https://github.com/pulumi/pulumi/issues/6700 . My workaround is to use config but with a different namespace and explicitly assign the settings and new up a Provider. Not optimal but unblocks me.
b

billowy-army-68599

04/04/2021, 6:27 PM
Thanks!