Is it possible to set an aws provider's endpoints ...
# aws
f
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
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
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
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
Yep am using the config map (.net version). Can't figure out the content/structure of the config value.
b
you're using localstack? just wanna make sure I'm recreating this accurately
❤️ 1
f
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
Copy code
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
this is what I'd expect to work:
Copy code
pulumi config set --path 'aws:endpoints[0].dynamodb' <http://localhost:4566>
but it doesn't, for whatever reason
Copy code
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
hmm
Copy code
❯ 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
Copy code
pulumi config set --path 'aws:endpoints[0]["dynamodb"]' <http://example.com>
Seems to work
so I believe your code would be:
Copy code
{"aws:endpoints[0]["dynamodb"], new ConfigValue("foo")}
f
will give it a go
Copy code
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:
Copy code
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
Copy code
config:
  aws:endpoints:
  - dynamodb: <http://example.com>
  aws:region: us-west-2
f
That's the result, what was the command? 🙂
b
Copy code
pulumi config set --path 'aws:endpoints[0]["dynamodb"]' <http://example.com>
f
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
it shouldn't be this hard, I know that much. I'm going to file an issue on Monday
👍 1
f
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
f
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
fun! Would you mind opening an issue around this experience? we need to make this better
f
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
Thanks!