1

I'm trying to use one of the outputs of my CloudFormation template as a parameter to a !cmd hook - e.g.

hooks:
  after_create:
    - !cmd "echo {{ value of cloudformation output }}"

Is there a way to do this?

Joseph Mansfield
  • 108,238
  • 20
  • 242
  • 324
Scott Odle
  • 290
  • 1
  • 2
  • 16
  • Hi Scott, looks like you might want to look at Resolvers for attempting this. https://sceptre.cloudreach.com/latest/docs/resolvers.html. You could add the value to sceptre_user_data and reference it from there. If you have a look at Hooks/Resolvers docs and let me know if that helps, otherwise I am happy to go in a more specific example (if you let me know what you want to do exaclty) and I can submit it as an answer – ngfgrant Jan 31 '18 at 12:05
  • Yeah sorry for the vague question. I have a CloudFormation template that outputs the MySQL hostname and port for a newly created RDS instance. I'm hoping that after the database is created, I can have Sceptre automatically run a SQL script against the new database from the command line: `mysql -h {{ new database hostname }} -P {{ new database port }} < db.sql` – Scott Odle Jan 31 '18 at 16:14
  • 1
    @ScottOdle I don't think this is possible at the moment without some pretty messy workarounds. If I were you, I'd just have a separate script that exports the stack outputs (using the `sceptre describe-stack-outputs` command, which has an option to export as environment variables) and runs your `mysql` command. – Joseph Mansfield Feb 18 '18 at 20:41
  • @JosephMansfield Yeah that's actually what I'm doing now. This seems like a pretty obvious missing feature, and it's rather annoying that when I posted this question on Sceptre's GitHub I was told to seek help on StackOverflow. – Scott Odle Feb 19 '18 at 00:30
  • Hi @ScottOdle - sorry that you are feeling frustrated. As we evolve Sceptre we try to keep our Github to feature requests, tasks and bugs. We are trying to encourage the use of StackOverflow for questions about Sceptre usage. Please feel free to submit your use-case phrased as a feature request. There is a contributors guide that should help answer any questions you might have about writing an issue. – ngfgrant Feb 19 '18 at 12:46
  • I want to do something similar; do some CLI postprocessing after the creation of a stack using some values of that stack. I implemented a custom hook but then the results of the stack aren't available. – Joost de Vries Jul 05 '18 at 10:43

0 Answers0