lively-needle-84406
11/16/2022, 7:22 PMcluster.core.cluster.name
within the policy json, but Typescript is complaining that cluster is undefined at runtime.
How can I ensure that the cluster is defined to remove the typescript compilation error? (I have already added a dependsOn to the Policy resource, with no luck)little-cartoon-10569
11/16/2022, 7:32 PM!
after whichever property has | undefined
in its type.lively-needle-84406
11/16/2022, 8:12 PMimport { aws } from "../../../lib";
import { cluster } from "../../eks";
export const clusterAutoscalerPolicy = new aws.iam.Policy(`clusterAutoscalerPolicy`, {
policy: `{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "VisualEditor0",
"Effect": "Allow",
"Action": [
"autoscaling:SetDesiredCapacity",
"autoscaling:TerminateInstanceInAutoScalingGroup"
],
"Resource": "*",
"Condition": {
"StringEquals": {
"aws:ResourceTag/k8s.io/cluster-autoscaler/${cluster.core.cluster.name}": "owned"
}
}
},
{
"Sid": "VisualEditor1",
"Effect": "Allow",
"Action": [
"autoscaling:DescribeAutoScalingInstances",
"autoscaling:DescribeAutoScalingGroups",
"ec2:DescribeLaunchTemplateVersions",
"autoscaling:DescribeTags",
"autoscaling:DescribeLaunchConfigurations"
],
"Resource": "*"
}
]
}`
}, {
dependsOn: [cluster]
});
Basically, cluster is undefined at this point and is throwing an error. But, I use cluster
similarly when creating other resources and never have this issue...little-cartoon-10569
11/16/2022, 8:12 PM"aws:ResourceTag/k8s.io/cluster-autoscaler/${cluster.core.cluster.name}": "owned"
pulumi.interpolate`aws:ResourceTag/k8s.io/cluster-autoscaler/${cluster.core.cluster.name}`: "owned"
lively-needle-84406
11/16/2022, 8:24 PMpolicy
property. I have attempted the pulumi.interpolate, but this has the same outcome:
import { aws, pulumi } from "../../../lib";
import { cluster } from "../../eks";
export const clusterAutoscalerPolicy = new aws.iam.Policy("clusterAutoscalerPolicy", {
policy: `{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "VisualEditor0",
"Effect": "Allow",
"Action": [
"autoscaling:SetDesiredCapacity",
"autoscaling:TerminateInstanceInAutoScalingGroup"
],
"Resource": "*",
"Condition": {
"StringEquals": {
${pulumi.interpolate`aws:ResourceTag/k8s.io/cluster-autoscaler/${cluster.core.cluster.name}: "owned"`}
}
}
},
{
"Sid": "VisualEditor1",
"Effect": "Allow",
"Action": [
"autoscaling:DescribeAutoScalingInstances",
"autoscaling:DescribeAutoScalingGroups",
"ec2:DescribeLaunchTemplateVersions",
"autoscaling:DescribeTags",
"autoscaling:DescribeLaunchConfigurations"
],
"Resource": "*"
}
]
}`
}, {
dependsOn: [cluster]
});
TypeError: Cannot read properties of undefined (reading 'core')
little-cartoon-10569
11/16/2022, 8:25 PMapply()
.lively-needle-84406
11/16/2022, 9:09 PMimport { aws, pulumi } from "../../../lib";
import { cluster } from "../../eks";
export const clusterAutoscalerPolicy = new aws.iam.Policy("clusterAutoscalerPolicy", {
policy: {
Version: "2012-10-17",
Statement: [
{
Sid: "VisualEditor0",
Effect: "Allow",
Action: [
"autoscaling:SetDesiredCapacity",
"autoscaling:TerminateInstanceInAutoScalingGroup"
],
Resource: "*",
Condition: {
StringEquals: {
[`${pulumi.interpolate`aws:ResourceTag/k8s.io/cluster-autoscaler/${cluster.core.cluster.name}`}`]: "owned"
}
}
},
{
Sid: "VisualEditor1",
Effect: "Allow",
Action: [
"autoscaling:DescribeAutoScalingInstances",
"autoscaling:DescribeAutoScalingGroups",
"ec2:DescribeLaunchTemplateVersions",
"autoscaling:DescribeTags",
"autoscaling:DescribeLaunchConfigurations"
],
Resource: "*"
}
]
}
});
Not sure how else to make the key the dynamic value herelittle-cartoon-10569
11/16/2022, 9:16 PMCondition: {
StringEquals: {
pulumi.interpolate`aws:ResourceTag/k8s.io/cluster-autoscaler/${cluster.core.cluster.name}`: "owned"
}
}
lively-needle-84406
11/16/2022, 9:18 PMType 'typeof import("/Users/jacobbaker/veryable/cloud/disaster-recovery/node_modules/@pulumi/pulumi/index")' is not assignable to type 'Input<string> | Input<Input<string>[]>'.
Type 'typeof import("/Users/jacobbaker/veryable/cloud/disaster-recovery/node_modules/@pulumi/pulumi/index")' is missing the following properties from type 'Input<string>[]': length, pop, push, join, and 25 more.ts(2322)
documents.d.ts(127, 5): The expected type comes from this index signature.
core
was undefined:
TypeError: Cannot read properties of undefined (reading 'core')
I logged cluster
and it has the type of OutputImpl
which I am assuming means that core
does not exist on this object.little-cartoon-10569
11/16/2022, 9:31 PMimport pulumi from "@pulumi/pulumi"
Instead of
import * as pulumi from "@pulumi/pulumi"
lively-needle-84406
11/16/2022, 9:36 PMexport * as pulumi from '@pulumi/pulumi';
I have tried to import pulumi as you mentioned above, directly in the file:
import * as pulumi from "@pulumi/pulumi"
But, receiving the same type errorlittle-cartoon-10569
11/16/2022, 9:38 PMType 'typeof import("/Users/jacobbaker/veryable/cloud/disaster-recovery/node_modules/@pulumi/pulumi/index")' is not assignable to type 'Input<string> | Input<Input<string>[]>'.
Is there anywhere in your code that is trying to use typeof import("/Users/jacobbaker/veryable/cloud/disaster-recovery/node_modules/@pulumi/pulumi/index")'
? That'll be the problem.lively-needle-84406
11/16/2022, 9:47 PMcore
is undefined, even with the pulumi.interpolate 😕little-cartoon-10569
11/16/2022, 9:49 PMcluster
is defined like this: import { cluster } from "../../eks";
Is it a static object with a core
property? Is it a module with a core
static object? It looks like you're using it as a variable, but it's not...lively-needle-84406
11/16/2022, 9:51 PMcluster
is the output of an eks.Cluster
, so my assumption was that whatever I am importing from this output, I could access directly. (I am able to access the cluster object properties in other places with no issues)little-cartoon-10569
11/16/2022, 9:53 PM