-
Notifications
You must be signed in to change notification settings - Fork 0
/
gcp-kms.yml
147 lines (147 loc) · 4.47 KB
/
gcp-kms.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
commands:
get-decrypt:
description: Decrypt Secret
parameters:
ciphertext-file:
description: File name to decipher
type: string
plaintext-file:
description: File name to store decipered file
type: string
location:
default: global
description: Location of kms keyring
type: string
keyring:
default: KMS_KEYRING
description: Kms keyring
type: env_var_name
key:
default: KMS_KEY
description: Kms key
type: env_var_name
bucket:
default: GCS_PIPELINE_BUCKET
description: Gcs bucket
type: env_var_name
object-path:
description: Gcs object path
type: string
steps:
- run:
command: |
gsutil cp gs://$GOOGLE_PROJECT_ID-$<<parameters.bucket>>/<<parameters.object-path>> .
gcloud kms decrypt \
--ciphertext-file <<parameters.ciphertext-file>> \
--plaintext-file <<parameters.plaintext-file>> \
--location global \
--keyring $<<parameters.keyring>> \
--key $<<parameters.key>>
name: Decrypt file
- persist_to_workspace:
root: /root/project
paths:
- hub
gcr-auth:
description: |
Configure gcloud cli.
parameters:
gcloud-service-key:
default: GCLOUD_SERVICE_KEY
description: The gcloud service key
type: env_var_name
google-compute-zone:
default: GOOGLE_COMPUTE_ZONE
description: |
The Google compute zone to connect with via the gcloud CLI
type: env_var_name
google-project-id:
default: GOOGLE_PROJECT_ID
description: |
Environment variable name for the Google project ID to connect with via the gcloud CLI
type: env_var_name
steps:
- gcp-cli/install
- gcp-cli/initialize:
gcloud-service-key: <<parameters.gcloud-service-key>>
google-compute-zone: <<parameters.google-compute-zone>>
google-project-id: <<parameters.google-project-id>>
description: |
An orb for working with Google Key Management Service (KMS). View this orb's source: https://github.com/carecloud-devops/orbs
examples:
get-decrypt:
description: |
Log into Google Cloud Plaform, then get object and decrypt
usage:
orbs:
gcp-kms: carecloud/[email protected]
version: 2.1
workflows:
get-decrypt:
jobs:
- gcp-kms/get-decrypt:
context: myContext
executors:
default:
description: A debian-based machine executor
docker:
- image: google/cloud-sdk
jobs:
get-and-decrypt:
description: |
Install GCP CLI, if needed, and configure. Get object and decrypt with KMS.
executor: default
parameters:
gcloud-service-key:
default: GCLOUD_SERVICE_KEY
description: The gcloud service key
type: env_var_name
google-compute-zone:
default: GOOGLE_COMPUTE_ZONE
description: The Google compute zone to connect with via the gcloud CLI
type: env_var_name
google-project-id:
default: GOOGLE_PROJECT_ID
description: The Google project ID to connect with via the gcloud CLI
type: env_var_name
ciphertext-file:
description: File name to decipher
type: string
plaintext-file:
description: File name to store decipered file
type: string
location:
default: global
description: Location of kms keyring
type: string
keyring:
default: KMS_KEYRING
description: Kms keyring
type: env_var_name
key:
default: KMS_KEY
description: Kms key
type: env_var_name
bucket:
description: Gcs bucket
type: env_var_name
object-path:
description: Gcs object path
type: string
steps:
- checkout
- gcr-auth:
gcloud-service-key: <<parameters.gcloud-service-key>>
google-compute-zone: <<parameters.google-compute-zone>>
google-project-id: <<parameters.google-project-id>>
- get-decrypt:
ciphertext-file: <<parameters.ciphertext-file>>
plaintext-file: <<parameters.plaintext-file>>
location: <<parameters.location>>
keyring: <<parameters.keyring>>
key: <<parameters.key>>
bucket: <<parameters.bucket>>
object-path: <<parameters.object-path>>
orbs:
gcp-cli: circleci/[email protected]
version: 2.1