polite-napkin-90098
12/16/2021, 9:09 PMeksRole, err := iam.NewRole(ctx, "eksRole", &iam.RoleArgs{
AssumeRolePolicyDocument: pulumi.Any{
Version: "2012-10-17",
Statement: []map[string]interface{}{
map[string]interface{}{
"effect": "Allow",
"principal": map[string]interface{}{
"service": []string{
"<http://eks.amazonaws.com|eks.amazonaws.com>",
},
},
"action": []string{
"sts:AssumeRole",
},
},
},
},
Path: pulumi.String("/"),
ManagedPolicyArns: pulumi.StringArray{
pulumi.String("arn:aws:iam::aws:policy/AmazonEKSClusterPolicy"),
pulumi.String("arn:aws:iam::aws:policy/AmazonEKSServicePolicy"),
},
})
if err != nil {
return err
}
But when I try and run that I get the following errors.
Diagnostics:
pulumi:pulumi:Stack (EKS-EKS-test):
# EKS
./main.go:77:30: pulumi.Any is not a type
./main.go:77:30: invalid composite literal type func(interface {}) pulumi.AnyOutput
error: an unhandled error occurred: program exited with non-zero exit code: 2
I have spent some time checking I copied the example well enough and I can't find any syntax errors, also when I copy the code from the example verbatim into my main.go and try to run it I get similar errors.
Did something change about pulumi.Any?
Is there an error in the example?
Please help!little-cartoon-10569
12/16/2021, 9:13 PMpolite-napkin-90098
12/16/2021, 9:15 PMimport { "<http://github.com/pulumi/pulumi/sdk/v3/go/pulumi|github.com/pulumi/pulumi/sdk/v3/go/pulumi>" }
at the top achieves that. I also expect the pulumi.String and pulumi.StringArray I used elsewhere would also fail if I hadn't.little-cartoon-10569
12/16/2021, 9:17 PM[]map[string]interface{}
bits might be fine for golangians, but it's hard to read for the rest of us. This style seems more grokable.polite-napkin-90098
12/16/2021, 9:19 PMlittle-cartoon-10569
12/16/2021, 9:19 PMpulumi.String(...)
approach, see if it fixes the problem?polite-napkin-90098
12/16/2021, 9:20 PMlittle-cartoon-10569
12/16/2021, 9:20 PMpulumi.Any
approach is probably relying on auto-conversion of objects to JSON under the Pulumi hood anyway. pulumi.String
is just making it a bit more explicit.polite-napkin-90098
12/16/2021, 9:25 PMaws-native:iam:Role (eksRole):
error: resource partially created but read failed. read error: reading resource state: operation error CloudControl: GetResource, https response error StatusCode: 400, RequestID: 37537079-4292-4a5b-a9f0-ff4d2da08801, ResourceNotFoundException: AWS::IAM::Role Handler returned status FAILED: The role with name eksRole-e2fc0f1 cannot be found. (Service: Iam, Status Code: 404, Request ID: e396cf09-f627-420f-8a5b-ebee365e73a1, Extended Request ID: null) (HandlerErrorCode: NotFound, RequestToken: e64d8096-1398-47b4-a8e4-c636b98ae8a2), create error: operation CREATE failed with "InvalidRequest": This policy contains invalid Json (Service: Iam, Status Code: 400, Request ID: ecf8171b-1d3f-4805-b714-3bd259667535, Extended Request ID: null)
and when I look at the details I see the JSON is like
+ aws-native:iam:Role: (create)
[urn=urn:pulumi:EKS-test::EKS::aws-native:iam:Role::eksRole]
assumeRolePolicyDocument: "{ \"Version\": \"2012-10-17\", \"Statement\": [{ \"Effect\": \"Allow\", \"Principal\": { \"Service\": \"<http://eks.amazonaws.com|eks.amazonaws.com>\", }, \"Action\": \"sts:AssumeRole\", }] }"
managedPolicyArns : [
So a bunch of \s I don't need or want. Which is I guess what the pulumi.Any{} was about.