great-sunset-355
11/09/2023, 3:42 PMconst a = new aws.Provider("a", {
region: "eu-central-1",
});
const b = new aws.Provider("2", {
region: "us-east-2",
});
// now inside the component resource
export class ComponentThing extends pulumi.ComponentResource {
public readonly taskDefinition: awsnative.ecs.TaskDefinition;
constructor(name: string, args: {}, opts?: pulumi.ComponentResourceOptions) {
super("myComponent", name, {}, opts);
const parent = this
new aws.acm.Certificate("ue1",{parent, provider: parent.getProvider('this should be us-east-1') })
new aws.acm.Certificate("ec1",{parent, provider: parent.getProvider('this should be eu-central-1') })
}}
Until now I've been explicitly passing providers via args
but opts
is IMO the correct way to do it, the question is how to get a proper provider from there?rhythmic-orange-74390
11/09/2023, 9:20 PMexport const a =
and then using them directly, instead of trying to pull them from some internal mechanism. I dont think parent.getProvder
here does what you expectexport const a = new aws.Provider("a", {
region: "eu-central-1",
});
export const b = new aws.Provider("2", {
region: "us-east-2",
});
// now inside the component resource
import {a, b} from "../aws_provders"
export class ComponentThing extends pulumi.ComponentResource {
public readonly taskDefinition: awsnative.ecs.TaskDefinition;
constructor(name: string, args: {}, opts?: pulumi.ComponentResourceOptions) {
super("myComponent", name, {}, opts);
const parent = this
new aws.acm.Certificate("ue1",{parent, provider: a})
new aws.acm.Certificate("ec1",{parent, provider: b})
}}
great-sunset-355
11/10/2023, 6:44 AMparent.getProvder
sure does what I expected it to do.rhythmic-orange-74390
11/10/2023, 4:35 PMgreat-sunset-355
11/11/2023, 3:51 PMimport * as aws from "@pulumi/aws";
import * as awsnative from "@pulumi/aws-native";
import * as pulumi from "@pulumi/pulumi";
const euCentral1 = aws.Region.EUCentral1;
const provider = new aws.Provider(euCentral1, {
region: euCentral1,
});
export class ComponentThing extends pulumi.ComponentResource {
public readonly taskDefinition: awsnative.ecs.TaskDefinition;
constructor(name: string, args: {}, opts?: pulumi.ComponentResourceOptions) {
super("providerTest", name, {}, opts);
const parent = this;
// parent.getProvider("2");
const role1 = new aws.iam.Role("role1", {
assumeRolePolicy: {
Version: "2012-10-17",
Statement: [
{
Effect: "Allow",
Principal: { Service: "<http://ecs-tasks.amazonaws.com|ecs-tasks.amazonaws.com>" },
Action: "sts:AssumeRole",
},
],
},
}, { parent });
const role2 = new awsnative.iam.Role("role2", {
assumeRolePolicyDocument: {
Version: "2012-10-17",
Statement: [
{
Effect: "Allow",
Principal: { Service: "<http://ecs-tasks.amazonaws.com|ecs-tasks.amazonaws.com>" },
Action: "sts:AssumeRole",
},
],
},
}, { parent });
const role3 = new aws.iam.Role("role3", {
assumeRolePolicy: {
Version: "2012-10-17",
Statement: [
{
Effect: "Allow",
Principal: { Service: "<http://ecs-tasks.amazonaws.com|ecs-tasks.amazonaws.com>" },
Action: "sts:AssumeRole",
},
],
},
}, { parent, provider: parent.getProvider("2") })
}
}
const parent = new aws.iam.Role("parent", {
assumeRolePolicy: {
Version: "2012-10-17",
Statement: [
{
Effect: "Allow",
Principal: { Service: "<http://ecs-tasks.amazonaws.com|ecs-tasks.amazonaws.com>" },
Action: "sts:AssumeRole",
},
],
},
}, { provider });
const native = new awsnative.Provider("native-provider", {
region: aws.getRegionOutput(undefined, { parent }).name as pulumi.Output<awsnative.Region>,
}, { parent });
const provider2 = new aws.Provider("2", {
region: aws.Region.USEast1,
});
// new ComponentThing("thing", {}, { parent, providers: { aws: provider, "aws-native": native }});
// new ComponentThing("thing", {}, { parent, provider: native });
new ComponentThing("thing", {}, { providers: [native, provider, provider2] });