1
+ locals {
2
+ has_encrypted_password = length (compact (aws_iam_user_login_profile. this . * . encrypted_password )) > 0
3
+ has_encrypted_secret = length (compact (aws_iam_access_key. this . * . encrypted_secret )) > 0
4
+ }
5
+
1
6
output "this_iam_user_name" {
2
7
description = " The user's name"
3
8
value = element (concat (aws_iam_user. this . * . name , [" " ]), 0 )
@@ -15,18 +20,12 @@ output "this_iam_user_unique_id" {
15
20
16
21
output "this_iam_user_login_profile_key_fingerprint" {
17
22
description = " The fingerprint of the PGP key used to encrypt the password"
18
- value = element (
19
- concat (aws_iam_user_login_profile. this . * . key_fingerprint , [" " ]),
20
- 0 ,
21
- )
23
+ value = element (concat (aws_iam_user_login_profile. this . * . key_fingerprint , [" " ]), 0 )
22
24
}
23
25
24
26
output "this_iam_user_login_profile_encrypted_password" {
25
27
description = " The encrypted password, base64 encoded"
26
- value = element (
27
- concat (aws_iam_user_login_profile. this . * . encrypted_password , [" " ]),
28
- 0 ,
29
- )
28
+ value = element (concat (aws_iam_user_login_profile. this . * . encrypted_password , [" " ]), 0 )
30
29
}
31
30
32
31
output "this_iam_access_key_id" {
@@ -37,7 +36,7 @@ output "this_iam_access_key_id" {
37
36
aws_iam_access_key. this_no_pgp . * . id ,
38
37
[" " ],
39
38
),
40
- 0 ,
39
+ 0
41
40
)
42
41
}
43
42
@@ -64,7 +63,7 @@ output "this_iam_access_key_ses_smtp_password_v4" {
64
63
aws_iam_access_key. this_no_pgp . * . ses_smtp_password_v4 ,
65
64
[" " ],
66
65
),
67
- 0 ,
66
+ 0
68
67
)
69
68
}
70
69
@@ -76,7 +75,7 @@ output "this_iam_access_key_status" {
76
75
aws_iam_access_key. this_no_pgp . * . status ,
77
76
[" " ],
78
77
),
79
- 0 ,
78
+ 0
80
79
)
81
80
}
82
81
@@ -87,42 +86,36 @@ output "pgp_key" {
87
86
88
87
output "keybase_password_decrypt_command" {
89
88
description = " Decrypt user password command"
90
- value = << EOF
91
- echo "${ element (
92
- concat (aws_iam_user_login_profile. this . * . encrypted_password , [" " ]),
93
- 0 ,
94
- )} " | base64 --decode | keybase pgp decrypt
89
+ value = ! local. has_encrypted_password ? null : << EOF
90
+ echo "${ element (concat (aws_iam_user_login_profile. this . * . encrypted_password , [" " ]), 0 )} " | base64 --decode | keybase pgp decrypt
95
91
EOF
96
92
97
93
}
98
94
99
95
output "keybase_password_pgp_message" {
100
96
description = " Encrypted password"
101
- value = << EOF
97
+ value = ! local . has_encrypted_password ? null : << EOF
102
98
-----BEGIN PGP MESSAGE-----
103
99
Version: Keybase OpenPGP v2.0.76
104
100
Comment: https://keybase.io/crypto
105
101
106
- ${ element (
107
- concat (aws_iam_user_login_profile. this . * . encrypted_password , [" " ]),
108
- 0 ,
109
- )}
102
+ ${ element (concat (aws_iam_user_login_profile. this . * . encrypted_password , [" " ]), 0 )}
110
103
-----END PGP MESSAGE-----
111
104
EOF
112
105
113
106
}
114
107
115
108
output "keybase_secret_key_decrypt_command" {
116
109
description = " Decrypt access secret key command"
117
- value = << EOF
110
+ value = ! local . has_encrypted_secret ? null : << EOF
118
111
echo "${ element (concat (aws_iam_access_key. this . * . encrypted_secret , [" " ]), 0 )} " | base64 --decode | keybase pgp decrypt
119
112
EOF
120
113
121
114
}
122
115
123
116
output "keybase_secret_key_pgp_message" {
124
117
description = " Encrypted access secret key"
125
- value = << EOF
118
+ value = ! local . has_encrypted_secret ? null : << EOF
126
119
-----BEGIN PGP MESSAGE-----
127
120
Version: Keybase OpenPGP v2.0.76
128
121
Comment: https://keybase.io/crypto
@@ -135,14 +128,10 @@ EOF
135
128
136
129
output "this_iam_user_ssh_key_ssh_public_key_id" {
137
130
description = " The unique identifier for the SSH public key"
138
- value = element (
139
- concat (aws_iam_user_ssh_key. this . * . ssh_public_key_id , [" " ]),
140
- 0 ,
141
- )
131
+ value = element (concat (aws_iam_user_ssh_key. this . * . ssh_public_key_id , [" " ]), 0 )
142
132
}
143
133
144
134
output "this_iam_user_ssh_key_fingerprint" {
145
135
description = " The MD5 message digest of the SSH public key"
146
136
value = element (concat (aws_iam_user_ssh_key. this . * . fingerprint , [" " ]), 0 )
147
137
}
148
-
0 commit comments