Skip to content

Commit

Permalink
Merge pull request #1611 from bschaatsbergen/google-compute-ssl-cert-…
Browse files Browse the repository at this point in the history
…support

Add `google_compute_ssl_certificate` resource
  • Loading branch information
Martin authored Feb 6, 2023
2 parents 5f863c7 + 1e44cef commit 3f4586d
Show file tree
Hide file tree
Showing 21 changed files with 441 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
package google

import (
remoteerror "github.com/snyk/driftctl/enumeration/remote/error"
"github.com/snyk/driftctl/enumeration/remote/google/repository"
"github.com/snyk/driftctl/enumeration/resource"
"github.com/snyk/driftctl/enumeration/resource/google"
)

type GoogleComputeSslCertificateEnumerator struct {
repository repository.AssetRepository
factory resource.ResourceFactory
}

func NewGoogleComputeSslCertificateEnumerator(repo repository.AssetRepository, factory resource.ResourceFactory) *GoogleComputeSslCertificateEnumerator {
return &GoogleComputeSslCertificateEnumerator{
repository: repo,
factory: factory,
}
}

func (e *GoogleComputeSslCertificateEnumerator) SupportedType() resource.ResourceType {
return google.GoogleComputeSslCertificateResourceType
}

func (e *GoogleComputeSslCertificateEnumerator) Enumerate() ([]*resource.Resource, error) {
sslCertificates, err := e.repository.SearchAllSslCertificates()
if err != nil {
return nil, remoteerror.NewResourceListingError(err, string(e.SupportedType()))
}

results := make([]*resource.Resource, 0, len(sslCertificates))
for _, res := range sslCertificates {
results = append(
results,
e.factory.CreateAbstractResource(
string(e.SupportedType()),
trimResourceName(res.GetName()),
map[string]interface{}{},
),
)
}

return results, err
}
1 change: 1 addition & 0 deletions enumeration/remote/google/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ func Init(version string, alerter alerter.AlerterInterface, providerLibrary *ter
remoteLibrary.AddEnumerator(NewGoogleComputeForwardingRuleEnumerator(assetRepository, factory))
remoteLibrary.AddEnumerator(NewGoogleComputeInstanceGroupManagerEnumerator(assetRepository, factory))
remoteLibrary.AddEnumerator(NewGoogleComputeGlobalForwardingRuleEnumerator(assetRepository, factory))
remoteLibrary.AddEnumerator(NewGoogleComputeSslCertificateEnumerator(assetRepository, factory))

return nil
}
7 changes: 7 additions & 0 deletions enumeration/remote/google/repository/asset.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ const (
computeForwardingRuleAssetType = "compute.googleapis.com/ForwardingRule"
instanceGroupManagerAssetType = "compute.googleapis.com/InstanceGroupManager"
computeGlobalForwardingRuleAssetType = "compute.googleapis.com/GlobalForwardingRule"
computeSslCertificateAssetType = "compute.googleapis.com/SslCertificate"
)

type AssetRepository interface {
Expand Down Expand Up @@ -64,6 +65,7 @@ type AssetRepository interface {
SearchAllForwardingRules() ([]*assetpb.Asset, error)
SearchAllInstanceGroupManagers() ([]*assetpb.Asset, error)
SearchAllGlobalForwardingRules() ([]*assetpb.Asset, error)
SearchAllSslCertificates() ([]*assetpb.Asset, error)
}

type assetRepository struct {
Expand Down Expand Up @@ -94,6 +96,7 @@ func (s assetRepository) listAllResources(ty string) ([]*assetpb.Asset, error) {
computeForwardingRuleAssetType,
instanceGroupManagerAssetType,
computeGlobalForwardingRuleAssetType,
computeSslCertificateAssetType,
},
}
var results []*assetpb.Asset
Expand Down Expand Up @@ -280,3 +283,7 @@ func (s assetRepository) SearchAllInstanceGroupManagers() ([]*assetpb.Asset, err
func (s assetRepository) SearchAllGlobalForwardingRules() ([]*assetpb.Asset, error) {
return s.listAllResources(computeGlobalForwardingRuleAssetType)
}

func (s assetRepository) SearchAllSslCertificates() ([]*assetpb.Asset, error) {
return s.listAllResources(computeSslCertificateAssetType)
}
40 changes: 39 additions & 1 deletion enumeration/remote/google/repository/mock_AssetRepository.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

106 changes: 106 additions & 0 deletions enumeration/remote/google_compute_scanner_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1507,6 +1507,112 @@ func TestGoogleComputeForwardingRule(t *testing.T) {
}
}

func TestGoogleComputeSslCertificate(t *testing.T) {
cases := []struct {
test string
assertExpected func(t *testing.T, got []*resource.Resource)
response []*assetpb.Asset
responseErr error
setupAlerterMock func(alerter *mocks.AlerterInterface)
wantErr error
}{
{
test: "no compute ssl certificates",
response: []*assetpb.Asset{},
assertExpected: func(t *testing.T, got []*resource.Resource) {
assert.Len(t, got, 0)
},
},
{
test: "multiple compute ssl certificates",
assertExpected: func(t *testing.T, got []*resource.Resource) {
assert.Len(t, got, 2)
assert.Equal(t, "projects/driftctl/regions/us-east1/sslCertificates/foo", got[0].ResourceId())
assert.Equal(t, "google_compute_ssl_certificate", got[0].ResourceType())

assert.Equal(t, "projects/driftctl/regions/us-east1/sslCertificates/bar", got[1].ResourceId())
assert.Equal(t, "google_compute_ssl_certificate", got[1].ResourceType())
},
response: []*assetpb.Asset{
{
AssetType: "compute.googleapis.com/SslCertificate",
Name: "//compute.googleapis.com/projects/driftctl/regions/us-east1/sslCertificates/foo",
},
{
AssetType: "compute.googleapis.com/SslCertificate",
Name: "//compute.googleapis.com/projects/driftctl/regions/us-east1/sslCertificates/bar",
},
},
},
{
test: "cannot list compute ssl certificates",
assertExpected: func(t *testing.T, got []*resource.Resource) {
assert.Len(t, got, 0)
},
responseErr: status.Error(codes.PermissionDenied, "The caller does not have permission"),
setupAlerterMock: func(alerter *mocks.AlerterInterface) {
alerter.On(
"SendAlert",
"google_compute_ssl_certificate",
alerts.NewRemoteAccessDeniedAlert(
common.RemoteGoogleTerraform,
remoteerr.NewResourceListingError(
status.Error(codes.PermissionDenied, "The caller does not have permission"),
"google_compute_ssl_certificate",
),
alerts.EnumerationPhase,
),
).Once()
},
},
}

factory := terraform.NewTerraformResourceFactory()

for _, c := range cases {
t.Run(c.test, func(tt *testing.T) {
scanOptions := ScannerOptions{}
providerLibrary := terraform.NewProviderLibrary()
remoteLibrary := common.NewRemoteLibrary()

// Initialize mocks
alerter := &mocks.AlerterInterface{}
if c.setupAlerterMock != nil {
c.setupAlerterMock(alerter)
}

assetClient, err := testgoogle.NewFakeAssertServerWithList(c.response, c.responseErr)
if err != nil {
tt.Fatal(err)
}

realProvider, err := terraform2.InitTestGoogleProvider(providerLibrary, "3.78.0")
if err != nil {
tt.Fatal(err)
}

repo := repository.NewAssetRepository(assetClient, realProvider.GetConfig(), cache.New(0))

remoteLibrary.AddEnumerator(google.NewGoogleComputeSslCertificateEnumerator(repo, factory))

testFilter := &enumeration.MockFilter{}
testFilter.On("IsTypeIgnored", mock.Anything).Return(false)

s := NewScanner(remoteLibrary, alerter, scanOptions, testFilter)
got, err := s.Resources()
assert.Equal(tt, err, c.wantErr)
if err != nil {
return
}
alerter.AssertExpectations(tt)
testFilter.AssertExpectations(tt)
if c.assertExpected != nil {
c.assertExpected(t, got)
}
})
}
}

func TestGoogleComputeInstanceGroupManager(t *testing.T) {

cases := []struct {
Expand Down
3 changes: 3 additions & 0 deletions enumeration/resource/google/google_compute_ssl_certificate.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package google

const GoogleComputeSslCertificateResourceType = "google_compute_ssl_certificate"
1 change: 1 addition & 0 deletions enumeration/resource/resource_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,7 @@ var supportedTypes = map[string]ResourceTypeMeta{
"google_compute_forwarding_rule": {},
"google_compute_instance_group_manager": {},
"google_compute_global_forwarding_rule": {},
"google_compute_ssl_certificate": {},

"azurerm_storage_account": {},
"azurerm_storage_container": {},
Expand Down
1 change: 1 addition & 0 deletions pkg/iac/terraform/state/terraform_state_reader_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -405,6 +405,7 @@ func TestTerraformStateReader_Google_Resources(t *testing.T) {
{name: "compute forwarding rule", dirName: "google_compute_forwarding_rule", wantErr: false},
{name: "compute instance group manager", dirName: "google_compute_instance_group_manager", wantErr: false},
{name: "compute global forwarding rule", dirName: "google_compute_global_forwarding_rule", wantErr: false},
{name: "compute ssl certificate", dirName: "google_compute_ssl_certificate", wantErr: false},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
[
{
"Id": "projects/driftctl/global/sslCertificates/my-certificate-6cb457f7",
"Type": "google_compute_ssl_certificate",
"Attrs": {
"certificate": "-----BEGIN CERTIFICATE-----\nMIIDjjCCAnYCCQCtS+GNvuG/2zANBgkqhkiG9w0BAQsFADCBiDELMAkGA1UEBhMC\nTkwxFjAUBgNVBAgMDU5vcnRoLUhvbGxhbmQxEjAQBgNVBAcMCUFtc3RlcmRhbTER\nMA8GA1UECgwIRHJpZnRDVEwxFDASBgNVBAMMC2V4YW1wbGUuY29tMSQwIgYJKoZI\nhvcNAQkBFhVkcmlmdGN0bEBkcmlmdGN0bC5jb20wHhcNMjMwMTExMTU1MDAyWhcN\nMjQwMTExMTU1MDAyWjCBiDELMAkGA1UEBhMCTkwxFjAUBgNVBAgMDU5vcnRoLUhv\nbGxhbmQxEjAQBgNVBAcMCUFtc3RlcmRhbTERMA8GA1UECgwIRHJpZnRDVEwxFDAS\nBgNVBAMMC2V4YW1wbGUuY29tMSQwIgYJKoZIhvcNAQkBFhVkcmlmdGN0bEBkcmlm\ndGN0bC5jb20wggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDGJiRMDAzL\nbsUnOKc8+spzWSfm2N1Lox/uTL8NkqzNNKCr5FVlJVKZcOLusmAzPs0UWJqG5Dmb\nsddOofKyfanZ12v/ADnwUH++uJ5e/0cgmK30jnvINqMrLzs2awt5XwD2PW2ZbAih\n292slOuXJt/KV+VZtP3UoUfp2Gl9qJbFpI/p2qem8udNyp6Q6XSKL4yWO4jPubN/\noJLGRqtaXwPW2wgAWtWfGbTA5o4xbMKu86r1DPB9e2QgduBPLnYJTjZtEC6HkEOk\n/c1Ht9IE40xCu+TAC5FNyOQv6hrSDyJUfUUnPix5Sgyet0Me+u1kMQ3F1qbw/bWA\n4mHgIk/waZdbAgMBAAEwDQYJKoZIhvcNAQELBQADggEBAENAaZXP5ECfGEw/rnRM\n5zfEudp+Y6H/ldGiaOr2E3t8qKOvDCbvV20dz1qvAbns3ol/dVByYRgQwc6GxWdz\nwhCDNUAj/22erTriAQbHfgPAa7Oi9LwBCmUmXqqA/KYOeWNXz9VrsUzCKlSIL7kX\noGuS1CmwNOSvE6AWpixS4epGUy4D721tIV90URhQGKvJmM3/KJe6ktiYxJ08mPLJ\n+8MkXUtZBAUhJUFYL+ZXBbh7lhg6yMDqkkDmraYumotMYwseuUz25PX9oglPyGB7\nmDwRDxz1VYpQ+TUtEwibv0FR6NXLOwZLorZVuZAxlzPJQNCHLAPQALd18CEVX6lq\nrmo=\n-----END CERTIFICATE-----\n",
"certificate_id": 8486823339612136543,
"creation_timestamp": "2023-01-11T07:50:08.574-08:00",
"description": "",
"id": "projects/driftctl/global/sslCertificates/my-certificate-6cb457f7",
"name": "my-certificate-6cb457f7",
"private_key": "-----BEGIN RSA PRIVATE KEY-----\nMIIEowIBAAKCAQEAxiYkTAwMy27FJzinPPrKc1kn5tjdS6Mf7ky/DZKszTSgq+RV\nZSVSmXDi7rJgMz7NFFiahuQ5m7HXTqHysn2p2ddr/wA58FB/vrieXv9HIJit9I57\nyDajKy87NmsLeV8A9j1tmWwIodvdrJTrlybfylflWbT91KFH6dhpfaiWxaSP6dqn\npvLnTcqekOl0ii+MljuIz7mzf6CSxkarWl8D1tsIAFrVnxm0wOaOMWzCrvOq9Qzw\nfXtkIHbgTy52CU42bRAuh5BDpP3NR7fSBONMQrvkwAuRTcjkL+oa0g8iVH1FJz4s\neUoMnrdDHvrtZDENxdam8P21gOJh4CJP8GmXWwIDAQABAoIBAGvNPnwdJizbY+mV\nue7EJragr8O5ApRu+CVGnb69qMOvuSYrgIYZyxltwBjK9OmMZjiGh/ORYQIivBes\npgSTt3+r4raGIf9rXESf3pGiYskKJ8HgbtmbWCRbeuR9Um3C0RwmiWUp0Hx2yOBm\n2NGQNbq5HS8z99DhueUwdxwFR5nYmvxwwZLvtNXNa6cS2DHRcKql8T6eEmTApi9n\nnx5MQZaeSZNoU4l8Cx0SW0DyHqNuWmmPHL8ICpYxlrrUB3+c4cdj6KKcjBniLZ7l\njP/FBzNbGUZa5JGAC52BcLbTLEIkxidIw4g2CwM1Ihdt+kSuimaV7w5bIpLdvp3G\nfRFacRECgYEA9SVAi9d6fcR279t7LgTs+s+QkcyR7dHyKdBMTjP5F13r3fGpLUMo\n0oMk58ZqTfvWCR/bkQcj1KilauNjagUvy93Un530stWRWZp7DdSX0YhI7LlTfZwR\nIh3V/Zzkd7dqkdEI7pTqD3BT8T7l/mG6fJC7ETCAwAglIWjZpdbtcfMCgYEAzuwt\n9u/DfLQCeWxJDYddys41pVKG70tlI65yIrERgp6ojjoEr8cA9I5vDqALg0Gv/R5w\nSdBUWLgvVi94HdUAX2Zjae6ljD2gTw0o6/wRYwvS+zt/V33JyTmcXacZMnZosTm2\nIxFul2HspAuieTm6db5MmtcjryxMsFNKR/OBtvkCgYA12G/cB4FtPIkPWDsvOX+/\n+3V6wN9QyGuTiaApETtmSYf0YQ9S1MyTqKCjlC5nYKh7qpa0vUe+fyiOWNHOSMNd\n2STJxo0n9scNUmQy/n42VOQHsxFGptAQmVMWeK6qKQxsaOi4VtcuevLFK5ajEF5A\n3B1qwieVhnR5aSldRt8yxwKBgCBoLOq3sk4dgyWxJ9/Oi4nvsccqnadsj3J/J7D3\nOl7SqmNcAs/kwumKRSptNmBgMUfbNIra7drXPdKprI4/hcdrKba1gYftPuYikX4k\nBDUW7Pwb3V2+fZPeSfcA7JlSoiLffv8PA9sBoyYuDEwgFmvKWgUGHLian4geA0wx\nfudBAoGBAKQZb9n3PvJfwSUhXqw+zv9PF+Av9GpPq7iGtg1JV3B2u++I/E8+Orrg\nT2K9DJL+VocN7WPcxxNLlB1CsD7/Kqwbc7P7q9NBpCrZ8SurhOv3YcFSfG+qTDAn\n+b83SrGV7SObUg8NS/vAu9LfYAyz3PllfteXaIvV/e9DMumXFKD1\n-----END RSA PRIVATE KEY-----\n",
"project": "driftctl",
"self_link": "https://www.googleapis.com/compute/v1/projects/driftctl/global/sslCertificates/my-certificate-6cb457f7"
}
}
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{
"version": 4,
"terraform_version": "1.3.7",
"serial": 5,
"lineage": "4c753da3-3a2d-b3e1-7dda-9434691ff386",
"outputs": {},
"resources": [
{
"mode": "managed",
"type": "google_compute_ssl_certificate",
"name": "default",
"provider": "provider[\"registry.terraform.io/hashicorp/google\"]",
"instances": [
{
"schema_version": 0,
"attributes": {
"certificate": "-----BEGIN CERTIFICATE-----\nMIIDjjCCAnYCCQCtS+GNvuG/2zANBgkqhkiG9w0BAQsFADCBiDELMAkGA1UEBhMC\nTkwxFjAUBgNVBAgMDU5vcnRoLUhvbGxhbmQxEjAQBgNVBAcMCUFtc3RlcmRhbTER\nMA8GA1UECgwIRHJpZnRDVEwxFDASBgNVBAMMC2V4YW1wbGUuY29tMSQwIgYJKoZI\nhvcNAQkBFhVkcmlmdGN0bEBkcmlmdGN0bC5jb20wHhcNMjMwMTExMTU1MDAyWhcN\nMjQwMTExMTU1MDAyWjCBiDELMAkGA1UEBhMCTkwxFjAUBgNVBAgMDU5vcnRoLUhv\nbGxhbmQxEjAQBgNVBAcMCUFtc3RlcmRhbTERMA8GA1UECgwIRHJpZnRDVEwxFDAS\nBgNVBAMMC2V4YW1wbGUuY29tMSQwIgYJKoZIhvcNAQkBFhVkcmlmdGN0bEBkcmlm\ndGN0bC5jb20wggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDGJiRMDAzL\nbsUnOKc8+spzWSfm2N1Lox/uTL8NkqzNNKCr5FVlJVKZcOLusmAzPs0UWJqG5Dmb\nsddOofKyfanZ12v/ADnwUH++uJ5e/0cgmK30jnvINqMrLzs2awt5XwD2PW2ZbAih\n292slOuXJt/KV+VZtP3UoUfp2Gl9qJbFpI/p2qem8udNyp6Q6XSKL4yWO4jPubN/\noJLGRqtaXwPW2wgAWtWfGbTA5o4xbMKu86r1DPB9e2QgduBPLnYJTjZtEC6HkEOk\n/c1Ht9IE40xCu+TAC5FNyOQv6hrSDyJUfUUnPix5Sgyet0Me+u1kMQ3F1qbw/bWA\n4mHgIk/waZdbAgMBAAEwDQYJKoZIhvcNAQELBQADggEBAENAaZXP5ECfGEw/rnRM\n5zfEudp+Y6H/ldGiaOr2E3t8qKOvDCbvV20dz1qvAbns3ol/dVByYRgQwc6GxWdz\nwhCDNUAj/22erTriAQbHfgPAa7Oi9LwBCmUmXqqA/KYOeWNXz9VrsUzCKlSIL7kX\noGuS1CmwNOSvE6AWpixS4epGUy4D721tIV90URhQGKvJmM3/KJe6ktiYxJ08mPLJ\n+8MkXUtZBAUhJUFYL+ZXBbh7lhg6yMDqkkDmraYumotMYwseuUz25PX9oglPyGB7\nmDwRDxz1VYpQ+TUtEwibv0FR6NXLOwZLorZVuZAxlzPJQNCHLAPQALd18CEVX6lq\nrmo=\n-----END CERTIFICATE-----\n",
"certificate_id": 8486823339612136543,
"creation_timestamp": "2023-01-11T07:50:08.574-08:00",
"description": "",
"id": "projects/driftctl/global/sslCertificates/my-certificate-6cb457f7",
"name": "my-certificate-6cb457f7",
"name_prefix": null,
"private_key": "-----BEGIN RSA PRIVATE KEY-----\nMIIEowIBAAKCAQEAxiYkTAwMy27FJzinPPrKc1kn5tjdS6Mf7ky/DZKszTSgq+RV\nZSVSmXDi7rJgMz7NFFiahuQ5m7HXTqHysn2p2ddr/wA58FB/vrieXv9HIJit9I57\nyDajKy87NmsLeV8A9j1tmWwIodvdrJTrlybfylflWbT91KFH6dhpfaiWxaSP6dqn\npvLnTcqekOl0ii+MljuIz7mzf6CSxkarWl8D1tsIAFrVnxm0wOaOMWzCrvOq9Qzw\nfXtkIHbgTy52CU42bRAuh5BDpP3NR7fSBONMQrvkwAuRTcjkL+oa0g8iVH1FJz4s\neUoMnrdDHvrtZDENxdam8P21gOJh4CJP8GmXWwIDAQABAoIBAGvNPnwdJizbY+mV\nue7EJragr8O5ApRu+CVGnb69qMOvuSYrgIYZyxltwBjK9OmMZjiGh/ORYQIivBes\npgSTt3+r4raGIf9rXESf3pGiYskKJ8HgbtmbWCRbeuR9Um3C0RwmiWUp0Hx2yOBm\n2NGQNbq5HS8z99DhueUwdxwFR5nYmvxwwZLvtNXNa6cS2DHRcKql8T6eEmTApi9n\nnx5MQZaeSZNoU4l8Cx0SW0DyHqNuWmmPHL8ICpYxlrrUB3+c4cdj6KKcjBniLZ7l\njP/FBzNbGUZa5JGAC52BcLbTLEIkxidIw4g2CwM1Ihdt+kSuimaV7w5bIpLdvp3G\nfRFacRECgYEA9SVAi9d6fcR279t7LgTs+s+QkcyR7dHyKdBMTjP5F13r3fGpLUMo\n0oMk58ZqTfvWCR/bkQcj1KilauNjagUvy93Un530stWRWZp7DdSX0YhI7LlTfZwR\nIh3V/Zzkd7dqkdEI7pTqD3BT8T7l/mG6fJC7ETCAwAglIWjZpdbtcfMCgYEAzuwt\n9u/DfLQCeWxJDYddys41pVKG70tlI65yIrERgp6ojjoEr8cA9I5vDqALg0Gv/R5w\nSdBUWLgvVi94HdUAX2Zjae6ljD2gTw0o6/wRYwvS+zt/V33JyTmcXacZMnZosTm2\nIxFul2HspAuieTm6db5MmtcjryxMsFNKR/OBtvkCgYA12G/cB4FtPIkPWDsvOX+/\n+3V6wN9QyGuTiaApETtmSYf0YQ9S1MyTqKCjlC5nYKh7qpa0vUe+fyiOWNHOSMNd\n2STJxo0n9scNUmQy/n42VOQHsxFGptAQmVMWeK6qKQxsaOi4VtcuevLFK5ajEF5A\n3B1qwieVhnR5aSldRt8yxwKBgCBoLOq3sk4dgyWxJ9/Oi4nvsccqnadsj3J/J7D3\nOl7SqmNcAs/kwumKRSptNmBgMUfbNIra7drXPdKprI4/hcdrKba1gYftPuYikX4k\nBDUW7Pwb3V2+fZPeSfcA7JlSoiLffv8PA9sBoyYuDEwgFmvKWgUGHLian4geA0wx\nfudBAoGBAKQZb9n3PvJfwSUhXqw+zv9PF+Av9GpPq7iGtg1JV3B2u++I/E8+Orrg\nT2K9DJL+VocN7WPcxxNLlB1CsD7/Kqwbc7P7q9NBpCrZ8SurhOv3YcFSfG+qTDAn\n+b83SrGV7SObUg8NS/vAu9LfYAyz3PllfteXaIvV/e9DMumXFKD1\n-----END RSA PRIVATE KEY-----\n",
"project": "driftctl",
"self_link": "https://www.googleapis.com/compute/v1/projects/driftctl/global/sslCertificates/my-certificate-6cb457f7",
"timeouts": null
},
"sensitive_attributes": [],
"private": "eyJlMmJmYjczMC1lY2FhLTExZTYtOGY4OC0zNDM2M2JjN2M0YzAiOnsiY3JlYXRlIjoxMjAwMDAwMDAwMDAwLCJkZWxldGUiOjEyMDAwMDAwMDAwMDB9fQ==",
"create_before_destroy": true
}
]
}
],
"check_results": null
}
3 changes: 3 additions & 0 deletions pkg/resource/google/google_compute_ssl_certificate.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package google

const GoogleComputeSslCertificateResourceType = "google_compute_ssl_certificate"
33 changes: 33 additions & 0 deletions pkg/resource/google/google_compute_ssl_certificate_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package google_test

import (
"testing"
"time"

"github.com/snyk/driftctl/test"
"github.com/snyk/driftctl/test/acceptance"
)

func TestAcc_Google_ComputeSslCertificate(t *testing.T) {
acceptance.Run(t, acceptance.AccTestCase{
TerraformVersion: "0.15.5",
Paths: []string{"./testdata/acc/google_compute_ssl_certificate"},
Args: []string{
"scan",
"--to", "gcp+tf",
},
Checks: []acceptance.AccCheck{
{
// New resources are not visible immediately through GCP API after an apply operation.
ShouldRetry: acceptance.LinearBackoff(10 * time.Minute),
Check: func(result *test.ScanResult, stdout string, err error) {
if err != nil {
t.Fatal(err)
}
result.AssertInfrastructureIsInSync()
result.AssertManagedCount(1)
},
},
},
})
}
1 change: 1 addition & 0 deletions pkg/resource/google/metadata_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ func TestGoogle_Metadata_Flags(t *testing.T) {
google.GoogleComputeForwardingRuleResourceType: {},
google.GoogleComputeInstanceGroupManagerResourceType: {},
google.GoogleComputeGlobalForwardingRuleResourceType: {},
google.GoogleComputeSslCertificateResourceType: {},
}

schemaRepository := testresource.InitFakeSchemaRepository("google", "3.78.0")
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*
!google_compute_ssl_certificate
Loading

0 comments on commit 3f4586d

Please sign in to comment.