Skip to content

Commit 4ea9d98

Browse files
omerdemirokactions-user
authored andcommitted
Add GCP Storage Transfer Transfer Job adapter (#2556)
Add GCP adapter for Storage Transfer Transfer Job with comprehensive blast propagation mapping for storage buckets, service accounts, Pub/Sub topics, and event streams. GitOrigin-RevId: ce6f14a274b9f60de46d7dc635afc2d63787ae7b
1 parent 001fa11 commit 4ea9d98

File tree

3 files changed

+113
-0
lines changed

3 files changed

+113
-0
lines changed
Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
package adapters
2+
3+
import (
4+
"fmt"
5+
6+
"github.com/overmindtech/cli/sdp-go"
7+
gcpshared "github.com/overmindtech/cli/sources/gcp/shared"
8+
)
9+
10+
// Storage Transfer Transfer Job facilitates data transfers between cloud storage systems and on-premises data
11+
// GCP Ref (GET): https://cloud.google.com/storage-transfer/docs/reference/rest/v1/transferJobs/get
12+
// GCP Ref (Schema): https://cloud.google.com/storage-transfer/docs/reference/rest/v1/transferJobs#TransferJob
13+
// GET https://storagetransfer.googleapis.com/v1/transferJobs/{jobName}
14+
// LIST https://storagetransfer.googleapis.com/v1/transferJobs
15+
var _ = registerableAdapter{
16+
sdpType: gcpshared.StorageTransferTransferJob,
17+
meta: gcpshared.AdapterMeta{
18+
SDPAdapterCategory: sdp.AdapterCategory_ADAPTER_CATEGORY_STORAGE,
19+
Scope: gcpshared.ScopeProject,
20+
GetEndpointBaseURLFunc: func(adapterInitParams ...string) (gcpshared.EndpointFunc, error) {
21+
if len(adapterInitParams) == 1 && adapterInitParams[0] != "" {
22+
return func(query string) string {
23+
if query != "" {
24+
// query is the job name, adapterInitParams[0] is the project ID
25+
return fmt.Sprintf("https://storagetransfer.googleapis.com/v1/transferJobs/%s?projectId=%s", query, adapterInitParams[0])
26+
}
27+
return ""
28+
}, nil
29+
}
30+
return nil, fmt.Errorf("projectID cannot be empty: %v", adapterInitParams)
31+
},
32+
ListEndpointFunc: gcpshared.ProjectLevelListFunc("https://storagetransfer.googleapis.com/v1/transferJobs?filter={\"projectId\":\"%s\"}"),
33+
UniqueAttributeKeys: []string{"transferJobs"},
34+
IAMPermissions: []string{
35+
"storagetransfer.jobs.get",
36+
"storagetransfer.jobs.list",
37+
},
38+
// TODO: https://linear.app/overmind/issue/ENG-631 status
39+
// https://cloud.google.com/storage-transfer/docs/reference/rest/v1/transferJobs#TransferJob.status
40+
},
41+
blastPropagation: map[string]*gcpshared.Impact{
42+
// Transfer spec references to source and destination storage
43+
"transferSpec.gcsDataSource.bucketName": {
44+
ToSDPItemType: gcpshared.StorageBucket,
45+
Description: "If the source GCS bucket is deleted or inaccessible: The transfer job will fail. If the transfer job is updated: The source bucket remains unaffected.",
46+
BlastPropagation: &sdp.BlastPropagation{
47+
In: true,
48+
},
49+
},
50+
"transferSpec.gcsDataSink.bucketName": {
51+
ToSDPItemType: gcpshared.StorageBucket,
52+
Description: "If the destination GCS bucket is deleted or inaccessible: The transfer job will fail. If the transfer job is updated: The destination bucket remains unaffected.",
53+
BlastPropagation: &sdp.BlastPropagation{
54+
In: true,
55+
},
56+
},
57+
// TODO: Investigate how we can link to AWS and Azure source when the account id (scope) is not available
58+
// https://cloud.google.com/storage-transfer/docs/reference/rest/v1/TransferSpec#AwsS3Data
59+
// https://cloud.google.com/storage-transfer/docs/reference/rest/v1/TransferSpec#AzureBlobStorageData
60+
"transferSpec.httpDataSource.listUrl": {
61+
ToSDPItemType: gcpshared.StorageBucket,
62+
Description: "HTTP data source URL for transfer operations. If the HTTP endpoint is unreachable: The transfer job will fail to access the source data.",
63+
BlastPropagation: &sdp.BlastPropagation{
64+
In: true,
65+
},
66+
},
67+
"transferSpec.gcsIntermediateDataLocation.bucketName": {
68+
ToSDPItemType: gcpshared.StorageBucket,
69+
Description: "If the destination GCS bucket is deleted or inaccessible: The transfer job will fail. If the transfer job is updated: The destination bucket remains unaffected.",
70+
BlastPropagation: &sdp.BlastPropagation{
71+
In: true,
72+
},
73+
},
74+
"serviceAccount": {
75+
ToSDPItemType: gcpshared.IAMServiceAccount,
76+
Description: "If the Service Account is deleted or permissions are revoked: The transfer job may fail to execute. If the transfer job is updated: The service account remains unaffected.",
77+
BlastPropagation: &sdp.BlastPropagation{
78+
In: true,
79+
},
80+
},
81+
// Notification configuration
82+
"notificationConfig.pubsubTopic": {
83+
ToSDPItemType: gcpshared.PubSubTopic,
84+
Description: "If the Pub/Sub Topic is deleted: Transfer job notifications will fail. If the transfer job is updated: The Pub/Sub topic remains unaffected.",
85+
BlastPropagation: &sdp.BlastPropagation{
86+
In: true,
87+
},
88+
},
89+
// TODO: Investigate whether we can/should support multiple items for a given key.
90+
// In this case, the eventStream can be an AWS SQS ARN in the form 'arn:aws:sqs:region:account_id:queue_name'
91+
// https://linear.app/overmind/issue/ENG-1348/investigate-supporting-multiple-items-in-blast-propagations
92+
"eventStream.name": {
93+
ToSDPItemType: gcpshared.PubSubTopic,
94+
Description: "If the Pub/Sub Topic for event streaming is deleted: Transfer job events will not be published. If the transfer job is updated: The Pub/Sub topic remains unaffected.",
95+
BlastPropagation: &sdp.BlastPropagation{
96+
In: true,
97+
},
98+
},
99+
},
100+
terraformMapping: gcpshared.TerraformMapping{
101+
Reference: "https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/storage_transfer_job",
102+
Description: "name => transferJobs/{jobName}",
103+
Mappings: []*sdp.TerraformMapping{
104+
{
105+
TerraformMethod: sdp.QueryMethod_GET,
106+
TerraformQueryMap: "google_storage_transfer_job.name",
107+
},
108+
},
109+
},
110+
}.Register()

sources/gcp/shared/item-types.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ var (
4646
BigQueryDataset = shared.NewItemType(GCP, BigQuery, Dataset)
4747
BigQueryDataTransferTransferConfig = shared.NewItemType(GCP, BigQueryDataTransfer, TransferConfig)
4848
BigQueryDataTransferDataSource = shared.NewItemType(GCP, BigQueryDataTransfer, DataSource)
49+
StorageTransferTransferJob = shared.NewItemType(GCP, StorageTransfer, TransferJob)
4950
PubSubSubscription = shared.NewItemType(GCP, PubSub, Subscription)
5051
PubSubTopic = shared.NewItemType(GCP, PubSub, Topic)
5152
CloudResourceManagerProject = shared.NewItemType(GCP, CloudResourceManager, Project)

sources/gcp/shared/models.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ const (
2929
ArtifactRegistry shared.API = "artifact-registry"
3030
Dataform shared.API = "dataform"
3131
Storage shared.API = "storage"
32+
StorageTransfer shared.API = "storage-transfer"
3233
ServiceDirectory shared.API = "service-directory"
3334
DNS shared.API = "dns"
3435
CloudBilling shared.API = "cloud-billing"
@@ -171,5 +172,6 @@ const (
171172
ExternalVpnGateway shared.Resource = "external-vpn-gateway"
172173
TransferConfig shared.Resource = "transfer-config"
173174
DataSource shared.Resource = "data-source"
175+
TransferJob shared.Resource = "transfer-job"
174176
SecurityCenterService shared.Resource = "security-center-service" // Used by Security Center Management
175177
)

0 commit comments

Comments
 (0)