Skip to content
This repository was archived by the owner on Apr 13, 2020. It is now read-only.

Conversation

@yradsmikham
Copy link
Collaborator

@yradsmikham yradsmikham commented Nov 13, 2019

  • Recursively reads definition.json files from parent to leaf directories
  • Creates a generated hierarchy resembling definition hierarchy
  • Copies appropriate Terraform templates to generated directory

Closes microsoft/bedrock#721.

@yradsmikham
Copy link
Collaborator Author

@NathanielRose apologies, if the documentation was not well-written. I'll spend more time improving it. Although, I'm trying to reproduce the issue you're experiencing, and am unable to do so.

So, there is such thing as running spk infra generate in a specific working directory in order to produce a specific outcome, and I'm thinking you could be running the command in different working directory. With your current tree structure, if you were to run spk infra generate -p discovery-service a level above the discovery-service directory, then this will produce a discovery-service-generated directory alongside the discovery-service level. This is considered a "single-tree" generation. So you would have:

discovery-service
    |- definition.json
    |- east/
    |   |- definition.json
    |- west/
        |- definition.json
discovery-service-generated
    |- backend.tfvars
    |- main.tf
    |- readme.md
    |- spk.tfvars
    |- terraform.tfvars
    |- variables.tf

If you want to generate for a specific region of the discovery-service, you should first cd into the discovery-service directory, and then run spk infra generate -p east. This will create the following:

discovery-service
    |- definition.json
    |- east/
    |   |- definition.json
    |- west/
        |- definition.json
discovery-service-generated
    |- east/
        |- main.tf
        |- readme.md
        |- spk.tfvars
        |- terraform.tfvars
        |- variables.tf

I will go ahead and update the documentation, so it has better instructions on how to use spk infra generate. I will also re-enable appending .backup to terraform.tfvars.

@andrebriggs andrebriggs self-requested a review November 14, 2019 19:24
@NathanielRose
Copy link
Collaborator

@yradsmikham Here is an exact repro:

  • Scenario 1
$ ./spk-linux infra scaffold --name discovery-service --source https://github.com/microsoft/bedrock --version "v0.12.0" --template cluster/environments/azure-single-keyvault
$ ./spk-linux infra scaffold --name discovery-service/east --source https://github.com/microsoft/bedrock --version "v0.12.0" --template cluster/environments/azure-simple
$ ./spk-linux infra scaffold --name discovery-service/west --source https://github.com/microsoft/bedrock --version "v0.12.0" --template cluster/environments/azure-simple
$ ./spk-linux infra generate --project discovery-service/
$ cd discovery-service/
$ ls
definition.json  east  -generated  west
$ Using File Explorer to rename -generated to discovery-generated
$ cd discovery-generated/
$ ls
backend.tfvars  main.tf  README.md  spk.tfvars  terraform.tfvars  variables.tf
  • Scenario 2
$ ./spk-linux infra scaffold --name discovery-service --source https://github.com/microsoft/bedrock --version "v0.12.0" --template cluster/environments/azure-single-keyvault
$ ./spk-linux infra scaffold --name discovery-service/east --source https://github.com/microsoft/bedrock --version "v0.12.0" --template cluster/environments/azure-simple
$ ./spk-linux infra scaffold --name discovery-service/west --source https://github.com/microsoft/bedrock --version "v0.12.0" --template cluster/environments/azure-simple
$ cd discovery-service/
$ ./spk-linux infra generate
$ cd ../discovery-service-generated/
$ ls
backend.tfvars  home  main.tf  README.md  spk.tfvars  terraform.tfvars  variables.tf

Where home has the folder path to discovery-service/

Copy link
Collaborator

@NathanielRose NathanielRose left a comment

Choose a reason for hiding this comment

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

lgtm - Works on Linux/windows
The current behavior for generate is based on - https://github.com/CatalystCode/bedrock-end-to-end-dx#generating-deployable-cluster-terraform-scripts
Enhanced Future functionality depicted here - microsoft/bedrock#791

Copy link
Contributor

@jmspring jmspring left a comment

Choose a reason for hiding this comment

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

The renaming of "terraform.tfvars" loop only renames the one file, not the others. Further, it continues to iterate once that single file is renamed. See note for preferred fix and possible error.

@yradsmikham yradsmikham requested a review from jmspring November 17, 2019 20:39
@yradsmikham
Copy link
Collaborator Author

@jmspring I removed the renaming functionality, and refactored the copyTfTemplate functionality to exclude the terraform.tfvars file.

@yradsmikham yradsmikham requested a review from edaena November 18, 2019 18:50
@yradsmikham yradsmikham dismissed jmspring’s stale review November 19, 2019 08:36

the requested changes have been resolved, user has not responded after several follow-ups.

@yradsmikham yradsmikham merged commit 86306ee into master Nov 19, 2019
@yradsmikham yradsmikham deleted the yvonne.infra.generate branch November 19, 2019 08:40
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Generate multi node spk template

7 participants