broad-helmet-79436
12/21/2021, 11:39 AMfaint-van-25343
12/22/2021, 5:35 PMpulumi.output(params.subnets).apply( s => s.filter(...))
), hoping that this filter function (https://www.pulumi.com/docs/reference/pkg/nodejs/pulumi/pulumi/#UnwrappedArray-filter) might resolve as intended.
type CreateVPCEndpointParams = {
vpc: aws.ec2.Vpc;
subnets: aws.ec2.Subnet[];
region: string;
provider: aws.Provider;
};
export const createVPCEndpoint = (params: CreateVPCEndpointParams) => {
const supported_azs = ['use1-az2', 'use1-az4', 'use1-az6'];
// FIXME: This filtering doesn't work. I think it's because the predicate returns an OutputInstance which is always truthy; it's not resolving the wrapped boolean?
const matching_subnets = params.subnets.filter((subnet) => {
return subnet.availabilityZoneId.apply((azid) => supported_azs.includes(azid));
});
return new aws.ec2.VpcEndpoint(
'elastic-co-endpoint',
{
vpcId: params.vpc.id,
serviceName: 'redacted.vpce-svc',
vpcEndpointType: 'Interface',
subnetIds: matching_subnets.map((subnet) => subnet.id),
},
{ provider: params.provider }
);
}
breezy-butcher-78604
12/23/2021, 3:18 AMimport * as pulumi from '@pulumi/pulumi';
import Ajv, { JTDDataType } from 'ajv/dist/jtd';
import repoConfigSchema from './config-schema.json';
// ...
however when running the program with pulumi up
i get the following error:
pulumi:pulumi:Stack (gh-repos-main):
error: Running program '<redacted>/src' failed with an unhandled exception:
TSError: ⨯ Unable to compile TypeScript:
config.ts(3,30): error TS2732: Cannot find module './config-schema.json'. Consider using '--resolveJsonModule' to import module with '.json' extension.
at createTSError (<redacted>/node_modules/ts-node/src/index.ts:261:12)
at getOutput (<redacted>/node_modules/ts-node/src/index.ts:367:40)
at Object.compile (<redacted>/node_modules/ts-node/src/index.ts:558:11)
at Module.m._compile (<redacted>/node_modules/ts-node/src/index.ts:439:43)
at Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
at Object.require.extensions.<computed> [as .ts] (<redacted>/node_modules/ts-node/src/index.ts:442:12)
at Module.load (internal/modules/cjs/loader.js:950:32)
at Function.Module._load (internal/modules/cjs/loader.js:790:14)
at Module.require (internal/modules/cjs/loader.js:974:19)
at require (internal/modules/cjs/helpers.js:92:18)
but i have enabled resolveJsonModule
in my tsconfig:
{
"$schema": "<https://json.schemastore.org/tsconfig>",
"display": "Node 14",
"compilerOptions": {
"target": "es2020",
"lib": [
"es2020"
],
"module": "commonjs",
"outDir": "dist/",
"strict": true,
"esModuleInterop": true,
"skipLibCheck": true,
"forceConsistentCasingInFileNames": true,
"resolveJsonModule": true
},
"include": [
"src/**/*.ts",
"src/**/*.json"
]
}
any ideas what I’m missing?refined-terabyte-65361
12/23/2021, 8:53 PMsome-church-49045
01/01/2022, 3:50 AMpulumi-nodejs:dynamic:Resource
. This generate duplicate resouce URN when the name of 2 different resource are the same . Is there a way to fix this ?crooked-dawn-93088
01/04/2022, 2:07 PMget
to import the default security group for further reference:
import * as aws from '@pulumi/aws';
import * as awsx from '@pulumi/awsx';
export const vpc = new awsx.ec2.Vpc('mdm-db-vpc', {
subnets: [{ type: 'isolated' }],
});
export const securityGroup = aws.ec2.SecurityGroup.get(
'default',
vpc.vpc.defaultSecurityGroupId,
);
breezy-bear-50708
01/04/2022, 3:08 PM"dependencies": {
"@pulumi/pulumi": "^3.0.0",
"typescript": "^3.8.0"
incalculable-midnight-8291
01/05/2022, 11:12 AMcluster.eksCluster.name.apply
seems to work a bit differently than I thought.
so basically using it like this seems to work:
cluster.eksCluster.name.apply((eksClusterName) => {
const nodegroup = new eks.NodeGroup(`${name}-nodegroup`, {
cluster,
instanceProfile,
labels: {
role: 'managed-nodes',
},
instanceType: 't2.medium',
desiredCapacity: 1,
minSize: 1,
maxSize: 3,
autoScalingGroupTags: {
['<http://k8s.io/cluster-autoscaler/enabled|k8s.io/cluster-autoscaler/enabled>']: 'true',
[`<http://k8s.io/cluster-autoscaler/${eksClusterName}`|k8s.io/cluster-autoscaler/${eksClusterName}`>]: 'owned',
},
});
------------
Original:
Hi!
Im trying to setup an eks cluster with k8s cluster autoscaler.
To get this to work, I need to tag the nodegroup with:
autoScalingGroupTags: {
['<http://k8s.io/cluster-autoscaler/enabled|k8s.io/cluster-autoscaler/enabled>']: 'true',
[`<http://k8s.io/cluster-autoscaler/${cluster.eksCluster.name}`|k8s.io/cluster-autoscaler/${cluster.eksCluster.name}`>]: 'owned',
},
However, the operation fails since Template format error: YAML not well-formed
Checking details shows that cluster.eksCluster.name
is never expanded to the name, instead it becomes: <http://k8s.io/cluster-autoscaler/Calling|k8s.io/cluster-autoscaler/Calling> [toString] on an [Output<T>] is not supported....
Im creating the cluster with
const cluster = new eks.Cluster(name, { options });
But the eks cluster dont just get the name name
, but ${name}-eksCluster-1234567
The number seems to be generated on creation, so I would really need some way of extracting it so I can use it in my tag.
I have tried `pulumi.interpolate`k8s.io/cluster-autoscaler/${cluster.eksCluster.name}`` and
cluster.eksCluster.name.apply(v => `<http://k8s.io/cluster-autoscaler/${v}`|k8s.io/cluster-autoscaler/${v}`>)
but they both fail with error TS2464: A computed property name must be of type 'string', 'number', 'symbol', or 'any'.
Any ideas?magnificent-lifeguard-15082
01/06/2022, 5:21 PMec2.Vpc.getSubnets
returns a Promise<ec2.Subnet[]>
as opposed to an Output<ec2.Subnet>[]
. Is this safe to use as an arg (Input) to a subsequent resource where I need to provide a subnet id?purple-megabyte-83002
01/11/2022, 3:13 PMcwd /Users/john/Desktop/nxapp/apps/app-web/src-infra
{
target: 'es6',
module: 'commonjs',
moduleResolution: 'node',
sourceMap: 'true',
baseUrl: '../../../',
paths: {
'@app/infra': [ 'libs/infra/src/index.ts' ],
},
traceResolution: true
}
error: Running program '/Users/john/Desktop/nxapp/apps/app-web/src-infra/main.ts' failed with an unhandled exception:
Error: Cannot find module '@app/infra'
Require stack:
- /Users/john/Desktop/nxapp/apps/app-web/src-infra/main.ts
- /Users/john/Desktop/nxapp/node_modules/@pulumi/pulumi/cmd/run/run.js
- /Users/john/Desktop/nxapp/node_modules/@pulumi/pulumi/cmd/run/index.js
at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)
at Function.Module._load (node:internal/modules/cjs/loader:778:27)
at Module.require (node:internal/modules/cjs/loader:1005:19)
at require (node:internal/modules/cjs/helpers:102:18)
at Object.<anonymous> (/Users/john/Desktop/nxapp/apps/app-web/src-infra/main.ts:1:1)
at Module._compile (node:internal/modules/cjs/loader:1101:14)
at Module.m._compile (/Users/john/Desktop/nxapp/node_modules/@pulumi/pulumi/node_modules/ts-node/src/index.ts:439:23)
at Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
at Object.require.extensions.<computed> [as .ts] (/Users/john/Desktop/nxapp/node_modules/@pulumi/pulumi/node_modules/ts-node/src/index.ts:442:12)
at Module.load (node:internal/modules/cjs/loader:981:32)
great-sunset-355
01/13/2022, 9:39 AMTS2322: Type 'Output<string | undefined>' is not assignable to type 'Input<string>'
Because dimmensions
is defined as
/**
* The dimensions for this metric. For the list of available dimensions see the AWS documentation [here](<http://docs.aws.amazon.com/AmazonCloudWatch/latest/DeveloperGuide/CW_Support_For_AWS.html>).
*/
dimensions?: pulumi.Input<{
[key: string]: pulumi.Input<string>;
}>;
Therefore I cannot use like this:
new aws.cloudwatch.MetricAlarm(
this.rcName('CpuHigh'),
{
...
dimensions: {
ClusterName: this.cluster.clusterName!,
ServiceName: this.service.name
}
}
)
I noticed a similar issue here: https://github.com/pulumi/pulumi-aws/pull/414
Is there any workaround for that?magnificent-lifeguard-15082
01/16/2022, 11:32 PMpulumi.json.stringify = (obj: JsonValueWithPotentialOutputsToJsonValue) => Output<string>
The return value here is an Output to a json string where the Output has collected all dependencies discovered while walking the passed object (JsonValueWithOutputs)
Edit: just use pulumi.output(obj).apply(uObj => JSON.stringify(uObj))
as output() deeply unwrapps 🎉 thanks pulumi team (lots of complexity is trivialised in the input/output api for us!)acoustic-room-2113
01/17/2022, 9:35 PMlet kmsPolicy: aws.iam.Policy;
try {
const vaultStack = new pulumi.StackReference(`vault-${env}`);
const vaultKey = vaultStack.getOutput(
"vaultKey"
) as pulumi.Output<aws.kms.Key>;
if (vaultKey != undefined && vaultKey != null) {
kmsPolicy = new aws.iam.Policy("vaultKMSUnsealPolicy", {
name: `VaultKMSUnsealKeyAccess-${env}`,
description: "Allow access to Vault Unseal Key",
policy: vaultKey.apply((key) =>
JSON.stringify({
Version: "2012-10-17",
Statement: [
{
Sid: "VaultKMSUnseal",
Effect: "Allow",
Action: ["kms:Encrypt", "kms:Decrypt", "kms:DescribeKey"],
Resource: key.arn,
},
],
})
),
});
}
} catch (e) {
console.log(e);
}
acoustic-room-2113
01/17/2022, 9:37 PMsparse-florist-83224
01/17/2022, 10:37 PMrefined-terabyte-65361
01/18/2022, 6:35 PMruntime: "go1.x"
I have code and dependencies in a directory how to run go build and zip while creating lambda function
i am using typescript for pulumi
runtime: nodejs
little-cartoon-10569
01/18/2022, 9:52 PMechoing-actor-55539
01/18/2022, 10:17 PMexport class CloudfrontInvalidationResource extends pulumi.dynamic.Resource implements CloudfrontInvalidationResourceOutputs {
public readonly cfDistributionId!: Output<ID>;
public readonly invalidationId!: Output<string>;
public readonly invalidationPaths!: Output<string[]>;
public readonly buildHash!: pulumi.Output<string>;
public readonly firstRun!: pulumi.Output<boolean>;
constructor(name: string, props: CloudfrontInvalidationResourceInputs, opts?: pulumi.CustomResourceOptions) {
const cfInvalidationProvider: pulumi.dynamic.ResourceProvider = {
check: async (olds: CloudfrontInvalidationResourceInputs, news: CloudfrontInvalidationResourceInputs): Promise<CheckResult> => {
console.log('******* check ' + name, {oldFirstRun: olds.firstRun, newFirstRun: news.firstRun, oldBuildHash: olds.buildHash, newBuildHash: news.buildHash});
const firstRun = !olds.buildHash;
return {
inputs: { ...news, firstRun }
};
},
Looks like the method invocation order is check(with old and new), diff, check(missing old values), createlittle-cartoon-10569
01/18/2022, 10:51 PMTypeError: Unknown file extension ".ts" for /pulumi/projects/myproj/index.tsIs there an example of a good package.json + tsconfig.json that works with type: module?
refined-terabyte-65361
01/19/2022, 12:37 AMimport { exec } from "child_process";
exec("./removeBuild.sh ", (err: any, stdout: any, stderr: any) => {
if (err) {
//some err occurred
console.error(err);
} else {
// the *entire* stdout and stderr (buffered)
console.log(`stdout: ${stdout}`);
console.log(`stderr: ${stderr}`);
}
});
busy-magazine-6225
01/22/2022, 1:01 AMbusy-magazine-6225
01/22/2022, 1:01 AMbusy-magazine-6225
01/22/2022, 1:05 AM/** Create vpc */
const vpc = new aws.ec2.Vpc(
`${opts.name}-vpc`,
{
cidrBlock: opts.vpcCidr,
enableDnsHostnames: true,
tags: { Name: `${opts.name}-vpc` }
},
{ parent: this }
);
/** Create internet gateway for VPC */
const internetGateway = new aws.ec2.InternetGateway(
`${opts.name}-igw`,
{
vpcId: vpc.id,
tags: { Name: `${opts.name}-igw` }
},
{ parent: this, dependsOn: vpc }
);
It always deletes the VPC firstbusy-magazine-6225
01/22/2022, 1:08 AMrefined-terabyte-65361
01/24/2022, 8:46 PMmagnificent-lifeguard-15082
01/28/2022, 1:28 PMwonderful-finland-34377
01/29/2022, 11:20 PMerror: an unhandled error occurred: Program exited with non-zero exit code: -1
no more information rather than this oneancient-monkey-64322
01/31/2022, 12:47 PMOutput<string[]>
to Output<string>[]
or Output<Record<string, string>>
to Record<string, Output<string>>
…microscopic-dress-1605
01/31/2022, 11:16 PMsteep-toddler-94095
02/02/2022, 12:10 AMpulumi preview
I'm running into a compile error that should not exist on typescript version 4.4+ when using template literals the way I'm using them Object literal may only specify known properties
steep-toddler-94095
02/02/2022, 12:10 AMpulumi preview
I'm running into a compile error that should not exist on typescript version 4.4+ when using template literals the way I'm using them Object literal may only specify known properties
little-cartoon-10569
02/02/2022, 1:03 AMsteep-toddler-94095
02/02/2022, 1:15 AM"ts-node": "^10.2.1",
"typescript": "^4.4.2"
the pulumi
CLI is using a different version of typescript. When I run similar code not through Pulumi CLI, I don't get an error.miniature-musician-31262
02/02/2022, 5:01 AM