This message was deleted.
# aws
s
This message was deleted.
f
g
GetRegion takes InvokeOptions argument which is essentially the same as ResourceOptions, so you pass in your own provider https://www.pulumi.com/registry/packages/aws/api-docs/getregion/#using
f
Well how do I do that with synced-folder ??? adding the normal `{provider: myProvider}`doesn't work
also tried:
{providers: {aws: myProvider} }
, always errors saying getRegion tries using default provider
g
yeah it does because the
synced-folder
code is just not well written with custom providers in mind. So you have to fork it and fix it so that you can pass your provider in 😞
it is the reason I avoid
awsx
and all pre-built components unfortunately
f
as I am deploying to multiple AWS accounts, I have on purpose disabled the default provider, to make sure things always specify where they should deploy
gahhh ... well thanks anyway
g
That's really good that you disabled default provider. I do it for all projects I can, except one giant where refactoring takes way too long.
f
yeah also ended up dropping awsx ... wasn't really playing nice with multiple providers indeed
also had other issues, like being unable to properly tag nested resources
g
nope, it is the legacy problem atm. basically author has to make sure to use
parent
with all resources inside the component resource otherwise they'll try to spawn default provider
f
FWIW: pulumi is wayyyy nicer at dealing with multiple accounts than CDK (which is a nightmare because of underlying CloudFormation limitations)
g
I've done a good bit of Terraform, CDK and Pulumi (multiple languages)
for Tagging I use transform, can share the snippet in Python or TS if you are interested
f
sure, I'm using TS ... also just FYI: former AWS employee, where I played a ton with CDK ... and then went back to pulumi after fighting with multi account issues 😛
g
xD
just wait till you open
awsnative
or
gcp native
pulumi of sadness
f
hah, don't get me started, thought I'd give
awsnative
a chance on new project ... but couldn't even build a basic VPC without running into things that weren't supported yet
FYI: issue with CDK is that CloudFormation does NOT support cross account stack references, so you have to jump all kinds of hoops to get info on a resource deployed in another account
g
So here is the idea of automatic tagging https://www.pulumi.com/blog/automatically-enforcing-aws-resource-tagging-policies/ it should lead to github project somewhere
f
thanks
g
but instead of using a "database" of resources in file, you can simple check if the resource has the right property, with a small adaptation this has worked with GCP as well.
Copy code
export function registerAutoTags(autoTags: Record<string, string>): void {
  if (!pulumi.runtime.getStackResource()) {
    return;
  }

  pulumi.runtime.registerStackTransformation((args) => {
    if ("tags" in args.props) {
      args.props["tags"] = { ...args.props["tags"], ...autoTags };
      return { props: args.props, opts: args.opts };
    }
    return undefined;
  });
}
l
@famous-jelly-72366 this is a bug. We forgot passing any explicit provider to the
aws.getRegion()
call here: https://github.com/pulumi/pulumi-synced-folder/blob/main/provider/cmd/pulumi-resource-synced-folder/s3-bucket-folder.ts#L39
f
that's what I figured, thanks for confirming
l
I’ll quickly create a PR for this.
@famous-jelly-72366 https://github.com/pulumi/pulumi-synced-folder/pull/18 I asked my engineering colleagues to review, merge and create a new release ASAP.
f
looks promising
g
Damn, you gotta love when @limited-rainbow-51650 joins the conversation and fixes just start flying! 🚀
😊 1
l
@famous-jelly-72366 This version should contain the fix: https://github.com/pulumi/pulumi-synced-folder/releases/tag/v0.10.2
f
Cool thanks, been having a few days of (winter holidays here), will take a look
Managed to test this out, seems to work. However if you assume it inherits provider from parent it will barf on not allowing default provider. So you have to be explicit.
l
The stack itself is implicitly the parent of every resource which doesn’t have an explicit parent set. This means that provider lookup starts at the child resource, passes via an explicit parent component resource to end up at the stack level, where it finds the default provider if nothing has an explicit provider set.
f
Ok, but I did set an explicit parent with an explicit provider ... which didn't work :S
l
@famous-jelly-72366 are you able to share some code? How do you pass the provider to the component resource? For components, you should use the
providers
(plural) resource option.
f
I already changed the code to something that was working, but what you mention might be the issue. So the parent was an S3 bucket with just
provider: myProvider
and the synced_folder had something like:
parent: myBucket
btw. thanks for responding 🙂
l
Ah, but your S3 bucket is not a Pulumi component resource. In this case, for 2 single resources, you indeed have to pass the explicit provider to each of the resources.
f
okay, not sure I understand what the distinction is here, what resources are 'component resources'?
l
Here is an intro to Pulumi component resources: https://www.pulumi.com/docs/intro/concepts/resources/components/
f
okay, but as a user of resources from 3rd party packages, like
aws
how would I easily be able to realize that this wouldn't work with S3 bucket? To me (as the user of the aws package) a S3 bucket is just a resource like a VPC
I think I now understand the issue, just trying to think on how to imporve DevX here 😄
l
You could make a pulumi component, wrapping your s3 bucket and synched folder resources as child resources. If you set the
parent
of each child resource to it’s wrapping component resource, you only have to pass your custom provider to the component and the provider lookup mechanism will do it’s magic.
f
ok, I understand, just thinking how to avoid others making same mistake as me. At least wasn't obvious that this would depend on the type of parent (simple vs. container). And how to spot if a resource is a container or not when coming from 3rd party