rhythmic-finland-36256
01/27/2020, 3:05 PMComponentResources
which is a nice way of abstracting a certain part of the whole into a separate file. This makes the projects more readable as we now can find resources easier than in a long list of resources inside a single index.ts file. As we also started using pulumi for more than just one project, I’d like to be able to reuse those components in other projects without copy/pasting single classes between them (which is already way better than to copy/paste many lines of resources from an index.ts).
So I’m looking for some hints on how to share those javascript/typescript files via npm. I already know a bit about npm publishing, but I’m specifically interested in how to deal with the dependencies my code has on pulumi classes and how the project setup generally looks. I assume those classes would go into a simple node project (not a pulumi project) with a common tsc
step.
• Is there some best practice project structure for such ComponentResource
libraries?
• How do you deal with testing the resources if there is no pulumi project? Having a separate repo for the pulumi project that uses the library via npm link?
• How to handle dependencies on pulumi resources? I assume the library should not bring specific versions of pulumi providers with it? Is using peerDependencies
the way to go?numerous-airport-64744
01/27/2020, 9:26 PMcluster.kubeConfigs[0].rawConfig
always returns the credentials from the time the cluster was actually created.
I tried to get the credentials by using a data source but I still have 2 problems with it:
• I’m unable to create a data source for the cluster from the generated name because GetKubernetesClusterArgs does not accept Output<string> as a name and my clusters name is dynamic.
• If I hard code the cluster name after it is being created the kubeconfig property of the k8s provider is changed on every pulumi up
-> pulumi:providers:kubernetes k8s updated [diff: ~kubeconfig]
Here are the relevant parts for clarification:
const cluster = new digitalocean.KubernetesCluster("cluster", {...});
const clusterDataSource = digitalocean.getKubernetesCluster({ name: cluster.name }); // error TS2322: Type 'Output<string>' is not assignable to type 'string'.
const kubeConfig = clusterDataSource.kubeConfigs[0].rawConfig;
const k8sProvider = new k8s.Provider("k8s", { kubeconfig: kubeConfig });
Any idea how to solve those two issues - primarily of course dynamic cluster name?clever-egg-2543
01/29/2020, 4:23 AMsquare-rocket-59657
01/30/2020, 8:14 AMclass myAwesomeClass {
... cool options here
}
awesome.ts
Then when creating my layer referencing it like:
const awesomeLayer = () => new aws.lambda.LayerVersion('my-lambda-version',
{
code: new pulumi.asset.AssetArchive({
'.': new pulumi.asset.FileArchive('./awesome.ts'),
}),
compatibleRuntimes: [
aws.lambda.NodeJS12dXRuntime,
aws.lambda.NodeJS10dXRuntime,
],
layerName: 'awesome_layer'
}, providerOpts);
The issue it that obviously the typescript file wont run in the lambda, is there a way that pulumi can compile this to normal JS? Or have i missed something?some-art-311
01/30/2020, 4:37 PMtsconfig.json
for Pulumi ?
If I drag the tsconfig.json
into the sub folder, it is working finesome-art-311
01/30/2020, 4:38 PMsome-art-311
01/30/2020, 4:38 PM{
"compilerOptions": {
"strict": true,
"outDir": "bin",
"target": "es2016",
"module": "commonjs",
"moduleResolution": "node",
"sourceMap": true,
"experimentalDecorators": true,
"pretty": true,
"noFallthroughCasesInSwitch": true,
"noImplicitReturns": true,
"forceConsistentCasingInFileNames": true,
"resolveJsonModule": true
},
"files": [
"index.ts"
]
}
some-art-311
01/30/2020, 4:38 PMcalm-parrot-72437
01/30/2020, 5:51 PMambitious-ram-5811
01/30/2020, 5:53 PMKeyPair
ambitious-ram-5811
01/30/2020, 5:53 PMcalm-parrot-72437
01/30/2020, 5:58 PMstocky-island-3676
01/31/2020, 9:06 AMbreezy-photographer-54783
01/31/2020, 2:44 PMacceptable-army-69872
01/31/2020, 5:57 PMconst vpc: aws.ec2.Vpc = apiStack.requireOutput("sharedServicesVpc");
tosses a type error.acceptable-army-69872
01/31/2020, 5:59 PMacceptable-army-69872
01/31/2020, 6:07 PMelegant-shampoo-65690
01/31/2020, 6:27 PMconst vpc: pulumi.Output<aws.ec2.Vpc> = apiStack.requireOutput("sharedServicesVpc").apply((value) => value as aws.ec2.Vpc);
acceptable-army-69872
01/31/2020, 6:46 PMType 'Output<Vpc>' is not assignable to type 'OutputInstance<Vpc>'.
acceptable-army-69872
01/31/2020, 6:51 PMfuture-megabyte-14556
02/03/2020, 8:42 AMeager-processor-51878
02/03/2020, 6:48 PMlimited-rainbow-51650
02/03/2020, 10:56 PMservice/index.ts
has:
export interface DatabaseOptions {
...
}
export class Service extends pulumi.ComponentResource {
...
}
The main index.ts
file, I has:
import * as backend from "./service";
const dbArgs = new backend.DatabaseOptions({
...
})
But I get an error on `DatabaseOptions`:
error: Running program '/Users/ringods/Projects/devops-sessions/pulumi/backend' failed with an unhandled exception:
TSError: ⨯ Unable to compile TypeScript:
index.ts(13,28): error TS2339: Property 'DatabaseOptions' does not exist on type 'typeof import(/Users/ringods/Projects/devops-sessions/pulumi/backend/service/index")'.
What am I missing here?handsome-actor-1155
02/04/2020, 5:04 PMexport const vpcZones = vpc.privateSubnetIds.then(function(subnetIds) {
return subnetIds.map(function (id) {
return id.apply(id => {
return aws.ec2.getSubnet({id: id}).availabilityZone;
});
});
});
victorious-helmet-11068
02/05/2020, 4:11 PMvictorious-helmet-11068
02/05/2020, 4:11 PMvictorious-helmet-11068
02/05/2020, 4:11 PMvictorious-helmet-11068
02/05/2020, 4:13 PMbitter-dentist-28132
02/05/2020, 6:37 PMexport const getSigningKey = (
secretKey: string | pulumi.Output<string>,
region: pulumi.Output<digitalocean.Region | aws.Region>
) => {...};
if (cloud === 'digitalocean') {
s3 = new digitalocean.SpacesBucket(env, {
region: awsRegion,
});
} else if (cloud === 'aws') {
s3 = new aws.s3.Bucket(env, {
region: awsRegion,
});
}
signingKey = getSigningKey(
awsSecretKey,
s3!.region
);
this doesn't work. it complains that the types for region
don't match. anyone know why?brave-window-69382
02/08/2020, 6:13 PMconst vpc = new awsx.ec2.Vpc('test', {})
const rts = aws.ec2.getRouteTables({
vpcId: vpc.id
});
When I bring up the stack, I'm getting the following error. I can't figure out how to transform pulumi.Output<string> into just a string.
index.ts(9,36): error TS2345: Argument of type '{ vpcId: pulumi.Output<string>; }' is not assignable to parameter of type 'GetRouteTablesArgs'.