little-market-63455
06/01/2021, 4:05 PMbrash-airline-37413
06/02/2021, 4:15 AMbitter-australia-87528
06/03/2021, 7:52 AMgreen-morning-1318
06/03/2021, 11:19 PMechoing-zebra-28421
06/04/2021, 2:29 PMechoing-zebra-28421
06/04/2021, 2:32 PM// Create the role for the Lambda to assume
const lambdaRole = new aws.iam.Role("lambdaRole", {
assumeRolePolicy: {
Version: "2012-10-17",
Statement: [
{
Action: "sts:AssumeRole",
Principal: {
Service: "<http://lambda.amazonaws.com|lambda.amazonaws.com>",
},
Effect: "Allow",
Sid: "",
},
],
},
});
// Attach the fullaccess policy to the Lambda role created above
const rolepolicyattachment = new aws.iam.RolePolicyAttachment(
"lambdaRoleAttachment",
{
role: lambdaRole,
policyArn: aws.iam.ManagedPolicy.AWSLambdaBasicExecutionRole,
}
);
// Create the Lambda to execute
const lambda = new aws.lambda.Function("lambdaFunction", {
code: new pulumi.asset.AssetArchive({
".": new pulumi.asset.FileArchive("./src/app"),
}),
runtime: "nodejs12.x",
role: lambdaRole.arn,
handler: "index.handler",
});
// Give API Gateway permissions to invoke the Lambda
const lambdapermission = new aws.lambda.Permission("lambdaPermission", {
action: "lambda:InvokeFunction",
principal: "<http://apigateway.amazonaws.com|apigateway.amazonaws.com>",
function: lambda,
});
// Set up the API Gateway
const apigw = new aws.apigatewayv2.Api("httpApiGateway", {
protocolType: "HTTP",
routeKey: "GET /",
target: lambda.invokeArn,
});
export const endpoint = apigw.apiEndpoint;
echoing-zebra-28421
06/04/2021, 2:36 PMechoing-zebra-28421
06/04/2021, 3:45 PMechoing-zebra-28421
06/04/2021, 3:46 PMconst api = new awsx.apigateway.API(`airship-api-${NODE_ENV}`, {
routes: [
{
path: "/",
method: "GET",
eventHandler: async (event: APIGatewayProxyEvent) => ({
statusCode: HttpStatus.OK,
body: "Hello, API Gateway V4!",
}),
},
{
path: "/api/named_users/associate",
method: "POST",
eventHandler: async (event: APIGatewayProxyEvent): Promise<any> => ({
statusCode: HttpStatus.OK,
body: JSON.stringify(await handleSetNamedUser(event)),
isBase64Encoded: false,
}),
},
{
path: "/api/channels/tags",
method: "POST",
eventHandler: async (event: APIGatewayProxyEvent) => ({
statusCode: HttpStatus.OK,
body: JSON.stringify(await handleSetTags(event)),
isBase64Encoded: false,
}),
},
],
});
I want to make something ifechoing-zebra-28421
06/06/2021, 1:38 AMMethod Map.prototype.has called on incompatible receiver #<Map>","stack":["TypeError: Method Map.prototype.has called on incompatible receiver #<Map>
curved-pharmacist-41509
06/07/2021, 5:01 AMgorgeous-country-43026
06/08/2021, 7:14 AMOutput
objects into one? I am aware of pulumi.all
but that has been defined for explicit amount of arguments and as such it doesn't work with Function.prototype.apply
as far as I see itgorgeous-country-43026
06/08/2021, 7:14 AMgorgeous-country-43026
06/08/2021, 7:18 AMpulumi.output(myArrayOfOutputs)
could do it... At least it returns a pulumi.UnwrappedArray
steep-toddler-94095
06/08/2021, 7:50 AMpulumi.all
for this
const asdf = [] as Array<Output<string>>
pulumi.all(asdf).apply(x=>x) // x will be type string[] here
echoing-zebra-28421
06/09/2021, 8:53 PMpulumi up -y -s dev
my error TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received an instance of Array
this is my tsconfig.ts
{
"compilerOptions": {
"baseUrl": "./src",
"paths": {
"@application/*": [
"application/*"
],
"@config/*": [
"config/*"
],
"@domain/*": [
"domain/*"
],
"@api-route": [
"api-route.ts"
],
"@interfaces/*": [
"interfaces/*"
]
},
"strict": true,
"outDir": "bin",
"target": "ESNEXT",
"lib": [
"ESNEXT"
],
"module": "commonjs",
"moduleResolution": "node",
"sourceMap": true,
"experimentalDecorators": true,
"pretty": true,
"noFallthroughCasesInSwitch": true,
"noImplicitReturns": true,
"esModuleInterop": true,
"emitDecoratorMetadata": true,
"skipLibCheck": true,
"forceConsistentCasingInFileNames": true,
"typeRoots": [
"./node_modules/@types"
],
"types": [
"@types/node",
"node"
]
},
"files": [
"src/handler.ts"
],
"include": [
"src/**/*.ts"
],
"exclude": [
"node_modules"
]
}
my package.json
{
"name": "api-notifications",
"scripts": {
"lint": "tslint -p tsconfig.json -c tslint.json",
"prettify": "prettier . --write"
},
"main": "src/handler.ts",
"devDependencies": {
"@types/aws-sdk": "^2.7.0",
"@types/dotenv": "^8.2.0",
"@types/node": "^10.17.60",
"typescript": "^4.2.4",
"tslint": "^6.1.3",
"tslint-config-airbnb": "^5.11.2"
},
"_moduleAliases": {
"@application": [
"bin/application"
],
"@config": [
"bin/config"
],
"@domain": [
"bin/domain"
],
"@interfaces": [
"bin/interfaces"
]
},
"dependencies": {
"@pulumi/aws": "^4.0.0",
"@pulumi/awsx": "^0.30.0",
"@pulumi/pulumi": "^3.0.0",
"@types/aws-lambda": "^8.10.76",
"axios": "^0.21.1",
"dotenv": "^9.0.2",
"module-alias": "^2.2.2"
}
}
Any idea or example to add the path aliases?
for example:
instead of this
import { CustomEventService } from "../../../application/services/custom-event/custom-event.service";
use this:
import { CustomEventService } from "@application/services/custom-event/custom-event.service";
in my ./src/handler.ts
I add
import "module-alias/register";
little-fish-42857
06/16/2021, 7:42 PMabundant-king-20145
06/16/2021, 10:22 PMError: Timeout of 2000ms exceeded. For async tests and hooks, ensure "done()" is called; if returning a Promise, ensure it resolves.
When you use a debugger the call ends when a resource is being created. Doing that things after the resource creation are unreachable:
Here is my test .
import * as pulumi from '@pulumi/pulumi';
import { MockCallArgs } from '@pulumi/pulumi/runtime';
import { describe, it, before } from 'mocha';
pulumi.runtime.setMocks({
newResource: function(args: pulumi.runtime.MockResourceArgs): {id: string, state: any} {
return {
id: args.inputs.name + "_id",
state: args.inputs,
};
},
call: function(args: MockCallArgs) {
return args.inputs;
},
});
describe('Example Service', () => {
let definitions: typeof import('./service-example');
before(async () => {
definitions = await import('./service-example');
})
it('should forward port 80 to 80', (done) => {
pulumi.all([definitions.ServiceExample]).apply(([ServiceExample]) => {
const se = new ServiceExample()
const service = se.aService;
done()
})
});
})
And my base class that I want to test.
import * as k8s from '@pulumi/kubernetes';
import {ComponentResource} from "@pulumi/pulumi";
export class ServiceExample extends ComponentResource{
private name: string = 'S1'
aService: k8s.core.v1.Service;
constructor() {
super('k8s:Service', 'S1');
this.aService = this.createService()
}
createService: () => k8s.core.v1.Service = () => {
return new k8s.core.v1.Service(
this.name = '-service',
{
metadata: {
name: this.name,
namespace: 'one'
},
spec: {
selector: {
foo: 'bar'
},
ports: [
{
name: 'http',
port: 80,
targetPort: 80}
]
}
}
)
}
}
And here is the repo if you want to clone it and test it on your own:
https://gitlab.com/diego.huerta/pulumi-exampleacceptable-army-69872
06/21/2021, 6:49 PM[{"Name":"", "Email": "", "Tags":"", "AdminRoles":[], "RORoles":[], "ZoneDelegation":[]}]
. It's a gross, but working fine. When I was just doing the roles, it was pretty easy to use a single loop where I created a provider per account. Now that I've added DNS, I'm thinking I'd like to have a single provider per account that I can pass around instead of a provider per account per type of activity. Seems like it could easily be an array of interfaces, that I access the right account provided doing some map/filters, or it could be a map type of <string, aws.Provider>
. Y'all got thoughts on which method may be prefered? Or should I go traipsing down the "turn your big gross json blob into objects, and store the provider in an account member" path?gorgeous-country-43026
06/22/2021, 9:04 AMOutput
abstraction is not a trivial task and I would assume Pulumi is actually under the hood generating YAML anyway from the definitions it would make sense if one could also export that data out somehow.
However, I think this is not possible since as far as I can see it, Pulumi automatically registers a resource to state when you say new <resourcetype
and you can't override this functionality, right?
If the answer to my question is what I think it is then my follow up question is: is there a ready tool or library function that could take in TypeScript data (objects, arrays etc) with Pulumi Output
and it would return a valid YAML string with Output
values properly populated?
If the answer to that one is "no" then I have one additional question: how can I reliably generate a string dynamically recursively in such a way that Output
objects are handled correctly? I actually wrote this simple "data to YAML" converter where I tried to handle the Output
objects correctly but unfortunately it doesn't seem to work that well...elegant-crayon-4967
06/22/2021, 9:37 PMbreezy-cricket-40277
06/25/2021, 4:41 PMgreen-daybreak-98726
06/29/2021, 11:35 PMpulumi up
a delete that had other requirements was running, then errored so which canceled out of the script.
• Tried to re-run pulumi up
, and the state now hangs on that part.
• Ran a pulumi refresh
to see if it resolved any issues, fails on:
error: the current deployment has 1 resource(s) with pending operations:
* {URN}, interrupted while deleting
• Tried running pulumi state delete {URN}
to manually remove problem resources, but get an error where it wants me to delete dependencies first but those dependencies don't exist anymore, so I cant technically delete them.
Out of curiosity, is the best way to resolve this to run pulumi stack export
fix the issues and reimport? Or is there a more elegant way to remove this corrupt state?cold-motherboard-287
07/01/2021, 2:57 PMComponentResource
? I need to use await
and inside of the constructor, AFAIK, is not possible.curved-pharmacist-41509
07/02/2021, 2:33 PMpulumi.output()
. It then can use pulumi’s input/output approach to handle itsteep-toddler-94095
07/02/2021, 11:29 PMtsconfig.json
file at the root of my repo? I'm getting an error when trying to use .flatMap
even though I have es2019
added to my root tsconfig's lib
. It only works if I create a new tsconfig inside the stack's dir but I'd like to avoid having to do this for every stackcold-motherboard-287
07/06/2021, 7:45 AMerror: Running program '/home/user/development/company/aws-iam-provisioning' failed with an unhandled exception:
Error: invocation of awsssm/getParametergetParameter returned an error: invoking awsssm/getParametergetParameter: 1 error occurred:
* Error describing SSM parameter (eks-name2): ParameterNotFound:
at Object.callback (/home/user/development/company/aws-iam-provisioning/node_modules/@pulumi/pulumi/runtime/invoke.js13933)
at Object.onReceiveStatus (/home/user/development/company/aws-iam-provisioning/node_modules/@grpc/grpc-js/src/client.ts33826)
at Object.onReceiveStatus (/home/user/development/company/aws-iam-provisioning/node_modules/@grpc/grpc-js/src/client-interceptors.ts42634)
at Object.onReceiveStatus (/home/user/development/company/aws-iam-provisioning/node_modules/@grpc/grpc-js/src/client-interceptors.ts38948)
at /home/user/development/company/aws-iam-provisioning/node_modules/@grpc/grpc-js/src/call-stream.ts27624
at processTicksAndRejections (nodeinternal/process/task queues78:11)
breezy-butcher-78604
07/07/2021, 3:32 AM@pulumi/aws
v3.0.0 to v3.38.1 causes the next pulumi up
to remove the AWS tags assigned to some (not all) resources in the stack?green-pencil-17360
07/07/2021, 10:59 PMpulumi up
. It actually forced me to set up the pass-phrase when I created the stack. It is throwing me the following error.
constructing secrets manager of type "passphrase": unable to find either `PULUMI_CONFIG_PASSPHRASE` or `PULUMI_CONFIG_PASSPHRASE_FILE` when trying to access the Passphrase Secrets Provider; please ensure one of these environment variables is set to allow the operation to continue
many-salesmen-89069
07/08/2021, 9:20 AMaws.lambda.CallbackFunction
, tutorials link to this page, but there is nothing there. Could somebody point me to the right direction?