hello i am trying to use pulumi up in github actio...
# typescript
r
hello i am trying to use pulumi up in github actions it works as expected . is there a way i can use the resource name from onestep to another ? i am already exporting the name of my bucket in my pulumi script
Copy code
import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";
import * as awsx from "@pulumi/awsx";

// Create an AWS resource (S3 Bucket)
const bucket = new aws.s3.Bucket("accessRequests3Bucket");

// Export the name of the bucket
export const bucketName = bucket.id;
i am able to see that in my github actions also
Copy code
pulumi up on dev
  Updating (dev):
  
  
  
      pulumi:pulumi:Stack s3-dev running 
  
      aws:s3:Bucket accessRequestBucket  
  
      pulumi:pulumi:Stack s3-dev  
   
  
  Outputs:
      bucketName: "accessrequestbucket-6500d31"
  
  Resources:
      2 unchanged
  
  Duration: 3s
apologies if this question is not related to pulumi Thanks
l
What will be using the name in the next step? If it's another Pulumi program, you would use a stack reference. If it's anything else, you would invoke
pulumi stack output
and grab the value from there.
r
it another github action step eg:
Copy code
- name: upload package to bucket
        run: aws s3 cp accessRequest.zip <s3-bucket-name>
i will try adding pulumi stack output thanks
👍 1
I tried like this but it command: output doesnt seem to work
Copy code
- uses: pulumi/actions@v3
        name: get s3 bucket name to push package 
        with:
          command: output
          stack-name: dev
          work-dir: awsResource/s3
        env:
          PULUMI_ACCESS_TOKEN: ${{ secrets.PULUMI_ACCESS_TOKEN }}
          PULUMI_CONFIG_PASSPHRASE: ${{ secrets.PULUMI_CONFIG_PASSPHRASE }}
error:
Copy code
Error: Expected { command: "up" | "update" | "refresh" | "destroy" | "preview"; stackName: string; workDir: string; commentOnPr: boolean; options: { parallel?: number; message?: string; expectNoChanges?: boolean; diff?: boolean; replace?: string[]; target?: string[]; targetDependents?: boolean; editCommentOnPr?: boolean; userAgent?: "pulumi/actions@v3"; }; }, but was incompatible
l
The Pulumi action doesn't support the
stack
command. If you need it in another step, then you need to run the
pulumi
command directly, and parse its output.
What's going to consume the name?
r
out put will be consumed by another github action step
Copy code
- uses: pulumi/actions@v3
        with:
          command: up
          stack-name: dev
          #comment-on-pr: true
          upsert: true
          refresh: true
          work-dir: awsResource/s3
        env:
          PULUMI_ACCESS_TOKEN: ${{ secrets.PULUMI_ACCESS_TOKEN }}
          PULUMI_CONFIG_PASSPHRASE: ${{ secrets.PULUMI_CONFIG_PASSPHRASE }}

      - name: upload foo package to bucket
        run: aws s3 cp foo.zip <bucket name from output of pulumi up >
l
Ah. If that can't be done in the Pulumi program (maybe by using a file asset) then you will want to use
pulumi stack output | grep bucketName
or similar. Unless the Pulumi action can store outputs in a workflow variable or similar... I don't think I've read anything about that.
r
This worked for me
Copy code
-  name: get s3 bucket name to push package
         id: pulumiStackOutput
         working-directory: awsResource/s3
         env:
          PULUMI_CONFIG_PASSPHRASE: ${{ secrets.PULUMI_CONFIG_PASSPHRASE }}
         run: echo ::set-output name=bucketname::$(pulumi login ${{ secrets.AWS_BUCKET }}  > /dev/null 2>&1  && pulumi stack output -j | jq -r .bucketName)
      -  name: print bucket name 
         run: echo ${{ steps.pulumiStackOutput.outputs.bucketname }}
l
Yep, it's a bit hairy, but maybe a request for an option to the "up" Pulumi action that puts outputs (or at least, some named outputs) into a workflow variable would be good...
Your solution is what I'd do, until the action supports something "prettier".