https://pulumi.com logo
Title
f

famous-jelly-72366

02/16/2023, 10:40 AM
How do I specify a specific AWS provider for synced-folder? I have default provider disabled (for good reasons) but having trouble getting sunced-folder working :S
g

great-sunset-355

02/16/2023, 12:36 PM
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

famous-jelly-72366

02/16/2023, 12:37 PM
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

great-sunset-355

02/16/2023, 12:39 PM
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

famous-jelly-72366

02/16/2023, 12:40 PM
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

great-sunset-355

02/16/2023, 12:41 PM
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

famous-jelly-72366

02/16/2023, 12:41 PM
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

great-sunset-355

02/16/2023, 12:42 PM
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

famous-jelly-72366

02/16/2023, 12:43 PM
FWIW: pulumi is wayyyy nicer at dealing with multiple accounts than CDK (which is a nightmare because of underlying CloudFormation limitations)
g

great-sunset-355

02/16/2023, 12:44 PM
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

famous-jelly-72366

02/16/2023, 12:46 PM
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

great-sunset-355

02/16/2023, 12:47 PM
xD
just wait till you open
awsnative
or
gcp native
pulumi of sadness
f

famous-jelly-72366

02/16/2023, 12:48 PM
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

great-sunset-355

02/16/2023, 12:51 PM
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

famous-jelly-72366

02/16/2023, 12:51 PM
thanks
g

great-sunset-355

02/16/2023, 12:53 PM
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.
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

limited-rainbow-51650

02/16/2023, 1:59 PM
@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

famous-jelly-72366

02/16/2023, 2:00 PM
that's what I figured, thanks for confirming
l

limited-rainbow-51650

02/16/2023, 2:00 PM
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

famous-jelly-72366

02/16/2023, 2:35 PM
looks promising
g

great-sunset-355

02/16/2023, 2:58 PM
Damn, you gotta love when @limited-rainbow-51650 joins the conversation and fixes just start flying! 🚀
l

limited-rainbow-51650

02/16/2023, 9:58 PM
@famous-jelly-72366 This version should contain the fix: https://github.com/pulumi/pulumi-synced-folder/releases/tag/v0.10.2
f

famous-jelly-72366

02/20/2023, 8:29 AM
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

limited-rainbow-51650

02/26/2023, 8:34 PM
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

famous-jelly-72366

02/27/2023, 7:34 AM
Ok, but I did set an explicit parent with an explicit provider ... which didn't work :S
l

limited-rainbow-51650

02/27/2023, 7:51 AM
@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

famous-jelly-72366

02/27/2023, 7:53 AM
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

limited-rainbow-51650

02/27/2023, 7:54 AM
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

famous-jelly-72366

02/27/2023, 7:55 AM
okay, not sure I understand what the distinction is here, what resources are 'component resources'?
l

limited-rainbow-51650

02/27/2023, 7:56 AM
Here is an intro to Pulumi component resources: https://www.pulumi.com/docs/intro/concepts/resources/components/
f

famous-jelly-72366

02/27/2023, 7:57 AM
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

limited-rainbow-51650

02/27/2023, 8:02 AM
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

famous-jelly-72366

02/27/2023, 8:04 AM
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