How can we get stack outputs into our CI variables...
# help
d
How can we get stack outputs into our CI variables?
t
haha I just sent a message to @Frank about making
sst-env
more generic
d
lol.. ya…. what is this magic that you speak of?
Something that exists or needs to be built?
I see it now… but trying to noodle if this could be used to export stack outputs to the CI
t
I think right now it's very tied to StaticSite
we also output stack outputs to
.build
folder as json
d
ah!
that works the charm
we can just use jq in CI to slurp those into CI
but I agree that having something in sst CLI would be best.
t
ah nice
yeah
d
hmmm
@thdxr but we aren’t seeing anything in
.build
t
ah have to specify it manually with
--outputs-file
d
@thdxr let me know if you create a issue for this and we’ll 👍 it
wait…. Don’t think this is going to work when all the outputs have hashes at the suffix.
c
Is this normal for the outputs to contain that hash? @thdxr
d
Just noticing that our actual outputs have hashes…
@thdxr I think this is because I didn’t know how to access
this.addOutputs()
from within my custom construct…. so I tried copying the source from
sst.Stack
Copy code
private addOutputs(outputs: { [key: string]: string | cdk.CfnOutputProps }): void {
    Object.keys(outputs).forEach((key) => {
      const value = outputs[key]
      if (value === undefined) {
        throw new Error(`The stack output "${key}" is undefined`)
      } else if (typeof value === 'string') {
        new cdk.CfnOutput(this, key, { value })
      } else {
        new cdk.CfnOutput(this, key, value)
      }
    })
  }
also tried this… which does not work….
Copy code
const stack = cdk.Stack.of(scope)
    stack.addOutputs({
      SERVICE: service,
      STAGE: stage,
      GIT_REPO,
      GIT_BRANCH: stage,
      SITE_URL: settings.siteUrl,
    })
  }
says that
addOutputs
is not part of stack
So I guess THAT stack is a
*cdk*.Stack
and not a
*sst*.Stack
?
t
Yeah you can cast it to
sst.Stack
which should work
f
@Dan Van Brunt @Camilo Bravo yeah, if you call
addOutputs
, those outputs won’t have hashes. The ones created by CDK automatically (values shared across stacks) have hashes.