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

Fix bootstrap script #623

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion lib/tasks/bootstrap.rake
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ namespace :bcn do
ENV["BOOTSTRAP_DATABASE_URL"] = "postgresql://#{stack.db_user}:#{db_password}@#{db_endpoint}:5432/#{stack.db_name}"
end

secret_key_base = SecureRandom.hex(64)

# Run oneoff task that runs inside the VPC and creates barcelona service and endpoint
heritage = district.heritages.new(
name: "barcelona-bootstrap",
Expand All @@ -68,6 +70,7 @@ namespace :bcn do
heritage.env_vars.build(key: "AWS_REGION", value: region, secret: false)
heritage.env_vars.build(key: "AWS_ACCESS_KEY_ID", value: access_key_id, secret: false)
heritage.env_vars.build(key: "AWS_SECRET_ACCESS_KEY", value: secret_key, secret: true)
heritage.env_vars.build(key: "SECRET_KEY_BASE", value: secret_key_base, secret: true)
heritage.env_vars.build(key: "RAILS_ENV", value: "production", secret: false)
heritage.env_vars.build(key: "RAILS_LOG_TO_STDOUT", value: "true", secret: false)
heritage.env_vars.build(key: "DISTRICT_NAME", value: district_name, secret: false)
Expand Down Expand Up @@ -142,7 +145,7 @@ EOS
{key: "RAILS_LOG_TO_STDOUT", value: "true", secret: false},
{key: "GITHUB_ORGANIZATION", value: ENV['GITHUB_ORGANIZATION'], secret: false},
{key: "DATABASE_URL", value: ENV["DATABASE_URL"], secret: true},
{key: "SECRET_KEY_BASE", value: SecureRandom.hex(64), secret: true},
{key: "SECRET_KEY_BASE", value: secret_key_base, secret: true},
Comment on lines -145 to +148
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I may be crazy, but it looks to me like this secret_key_base local variable is defined in the task bcn:bootstrap, and right here it is being used by the task bcn:bootstrap:remote. Those are different Ruby scopes so I suspect this line here will error out.

We can probably just keep the inline call to SecureRandom.hex(64) here, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh yeah. That is odd. I wonder why this worked... It may have been because the variable was re-evaluated. You're right. It can just be the same key base here too.

{key: "ENCRYPTION_KEY", value: ENV["ENCRYPTION_KEY"], secret: true}
],
services_attributes: [
Expand Down