Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sfn doesn't resolve ref for output used in nested template (v. 3.0.18) #218

Open
ls-yann-david opened this issue Jul 27, 2016 · 9 comments

Comments

@ls-yann-david
Copy link

ls-yann-david commented Jul 27, 2016

Hey, I currently upgraded SFN from 2.2.0 to 3.0.18 and now on sfn update/create I get this:

[Sfn]: SparkleFormation: update
[Sfn]:   -> Name: elasticsearch-devevelopment Path: /Users/yann.david/Development/devtools/sfn/sfn-provision_devtools/sparkleformation/templates/elasticsearch/core.rb
[Sfn]: Stack runtime parameters: - template: elasticsearch-devevelopment
[Sfn]: Env Product [{"Ref"=>"EnvProduct"}]:
[Sfn]: Env Name [{"Ref"=>"EnvName"}]:
[Sfn]: Env Revision [{"Ref"=>"EnvRevision"}]:
[Sfn]: App Name [{"Ref"=>"AppName"}]:
[Sfn]: Env Short [{"Ref"=>"EnvShort"}]:
[Sfn]: Ami Id [{"Ref"=>"AmiId"}]:
[Sfn]: Chef Version [{"Ref"=>"ChefVersion"}]: 
[Sfn]: Key Name [{"Ref"=>"KeyName"}]: 

From the template:

  outputs do
    env_product.value ref!(:env_product)
    env_name.value ref!(:env_name)
    env_revision.value ref!(:env_revision)
    app_name.value ref!(:app_name)
    env_short.value ref!(:env_short)
    ami_id.value ref!(:ami_id)
    chef_version.value ref!(:chef_version)
    key_name.value ref!(:key_name)
  end

and the registry:

SfnRegistry.register(:core_params) do
  parameters do
    env_product do
      type "String"
      description "Stack product name ex.:"
    end

    env_name do
      type "String"
      description "Stack product environment ex.: production, staging, development"
    end

    env_revision do
      type "String"
      description "Stack version or revision"
      default ::Time.new.strftime("%Y%m%d%H%M%S")
    end

    app_name do
      type "String"
      description "Stack application name ex.: frontend, backend, api"
    end

    env_short do
      type "String"
      description "Short name of environment: stg, dev, prod"
    end
  end
end

and

SfnRegistry.register(:elasticsearch_instances_params) do
  parameters do
    ami_id do
      type "String"
      description "AMI id to use throughout the ASG"
      default "XXXX"
    end

    chef_version do
      type "String"
      description "Chef version to install on the node"
      default "XXXX"
    end

    key_name do
      type "String"
      description "SSH Key used as the default user (Bootstrap)"
      default "XXXXX"
    end
  end
end

I can overwrite them at prompt, but no matter what I do EVERY UPDATE will put {REF...} as the default value instead of filling the values from CF (the values are there on the stack in AWS).

Any idea what could cause that? It's only on those parameters. Nested template parameters are resolving correctly.

@chrisroberts
Copy link
Member

Are these parameters in the root template that show up like this? What style of nesting do you have configured?

@ls-yann-david
Copy link
Author

ls-yann-david commented Jul 28, 2016

Yes, those parameters are in the root template. I use the default one (Shallow I think?), I didn't change anything from default when I started using SFN/SparkleFormation so whatever is the default behaviour of nest!()

@ls-yann-david
Copy link
Author

Any idea on what caused this issue? I haven't retried it yet and have downgraded to my previous sfn version.

@ls-yann-david
Copy link
Author

I guess not...

@chrisroberts
Copy link
Member

Hi! Apologies for the delay, some outside forces consumed quite a bit of my time recently. A couple questions regarding this issue as I'm having a hard time reproducing this locally:

  1. Do you have a configuration setting in your .sfn file for apply_nesting ?
  2. Does this behavior happen on create and update, or just update ?

Thanks!

@chrisroberts chrisroberts reopened this Oct 18, 2016
@Typositoire
Copy link

Hey! Welcome back :P We were starting to think you were dead xD (I have 2 accounts sorry)

I will ping you tomorrow when I can take a look at my config! Just making sure you don't think I ignore you :p

@Typositoire
Copy link

So I just tried again and it only applies to sfn update for my top template (all the nested template now have correct attribute) but here's what I get for the TOP template

[Sfn]:   -> Name: logstash-development-v2 Path: /Users/yann.david/Development/devtools/sfn/sfn-provision_devtools/sparkleformation/templates/logstash/core.rb
[Sfn]: Stack runtime parameters: - template: logstash-development-v2
[Sfn]: Env Product [{"Ref"=>"EnvProduct"}]: devtools
[Sfn]: Env Name [{"Ref"=>"EnvName"}]: development
[Sfn]: Env Revision [{"Ref"=>"EnvRevision"}]: 20160506093433
[Sfn]: App Name [{"Ref"=>"AppName"}]: logstash
[Sfn]: Env Short [{"Ref"=>"EnvShort"}]: dev

Nested Template are good

[Sfn]: Stack runtime parameters: - template: logstash-development-v2 > LogstashCacheCluster
[Sfn]: Automatic Failover Enabled [false]:
[Sfn]: Cache Node Type [cache.m1.small]:
[Sfn]: Cache Parameter Group Name [default.redis2.8]:
[Sfn]: Engine [redis]:
[Sfn]: Engine Version [2.8.24]:
[Sfn]: Notification Topic Arn [none]:
[Sfn]: Num Cache Clusters [1]:
[Sfn]: Security Group Ids [sg-d8f8d4bc]:
[Sfn]: Subnet Ids [subnet-8dd66dfa,subnet-f6a86fdd]:

Here's my top template

#
# Configuration
#
tpl_name = :logstash_core
tpl_description = 'Logstash core - Receivers, Processors and Redis'

#
# Create the template and inject policy objects
#
template = SparkleFormation.new(tpl_name) do

  registry! :core_params

  nest!(:logstash_cache_cluster)
  nest!(:logstash_receivers)
  nest!(:logstash_processors)

  outputs do
    env_product.value ref!(:env_product)
    env_name.value ref!(:env_name)
    env_revision.value ref!(:env_revision)
    app_name.value ref!(:app_name)
    env_short.value ref!(:env_short)
  end
end

@chrisroberts
Copy link
Member

Okay, I've got a reproduction of this behavior going locally so I should have it fixed up soon 😃

@slyness
Copy link
Member

slyness commented Feb 11, 2017

@chrisroberts how about this one? Any chance it was resolved in the recent release?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants