Skip to content

Commit a274e8d

Browse files
committed
Fixes for cognito output handling
1 parent 61c8393 commit a274e8d

File tree

7 files changed

+33
-5
lines changed

7 files changed

+33
-5
lines changed

internal/generate/terraform/generate.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,10 @@ func GetOutputs(config *config.Commit0Config, pathPrefix string, outputs []strin
4545

4646
envars := util.MakeAwsEnvars(util.GetSecrets())
4747

48-
path := filepath.Join(pathPrefix, "terraform")
48+
pathPrefix = filepath.Join(pathPrefix, "environments/staging")
4949

5050
for _, output := range outputs {
51-
outputValue := util.ExecuteCommandOutput(exec.Command("terraform", "output", output), path, envars)
51+
outputValue := util.ExecuteCommandOutput(exec.Command("terraform", "output", output), pathPrefix, envars)
5252
outputsMap[output] = outputValue
5353
}
5454

internal/util/util.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ func ExecuteCommandOutput(cmd *exec.Cmd, pathPrefix string, envars []string) str
136136

137137
out, err := cmd.CombinedOutput()
138138
if err != nil {
139-
log.Fatalf("Executing terraform output failed: %v\n", err)
139+
log.Fatalf("Executing command failed: (%v) %s\n", err, out)
140140
}
141141
return string(out)
142142
}

templates/terraform/environments/development/main.tf

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,3 +38,11 @@ module "development" {
3838
s3_hosting_bucket_name = "{{ .Config.Name }}-development"
3939

4040
}
41+
42+
output "cognito_client_id" {
43+
value = module.staging.cognito.cognito_client_id
44+
}
45+
46+
output "cognito_pool_id" {
47+
value = module.staging.cognito.cognito_pool_id
48+
}

templates/terraform/environments/production/main.tf

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,3 +38,11 @@ module "production" {
3838
s3_hosting_bucket_name = "{{ .Config.Name }}-production"
3939

4040
}
41+
42+
output "cognito_client_id" {
43+
value = module.staging.cognito.cognito_client_id
44+
}
45+
46+
output "cognito_pool_id" {
47+
value = module.staging.cognito.cognito_pool_id
48+
}

templates/terraform/environments/staging/main.tf

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,11 @@ module "staging" {
3737
hostname = "{{ .Config.Frontend.Hostname }}"
3838
s3_hosting_bucket_name = "{{ .Config.Name }}-staging"
3939
}
40+
41+
output "cognito_client_id" {
42+
value = module.staging.cognito.cognito_client_id
43+
}
44+
45+
output "cognito_pool_id" {
46+
value = module.staging.cognito.cognito_pool_id
47+
}

templates/terraform/modules/cognito/main.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ resource "aws_cognito_user_pool_client" "client" {
3333
}
3434

3535
output "cognito_pool_id" {
36-
value = "${aws_cognito_user_pool.users.id}"
36+
value = aws_cognito_user_pool.users.id
3737
}
3838
output "cognito_client_id" {
39-
value = "${aws_cognito_user_pool_client.client.id}"
39+
value = aws_cognito_user_pool_client.client.id
4040
}

templates/terraform/modules/environment/main.tf

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,10 @@ module "cognito" {
4949
user_pool = var.user_pool
5050
hostname = var.hostname
5151
}
52+
53+
output "cognito" {
54+
value = module.cognito
55+
}
5256
# {{- end}}
5357

5458
# {{ if .Config.Infrastructure.AWS.S3Hosting.Enabled }}

0 commit comments

Comments
 (0)