Merge pull request #1242 from snyk/feat/add_aws_launch_configuration
Add aws_launch_configurationmain
commit
790ecf9c08
|
@ -179,6 +179,7 @@ func TestTerraformStateReader_AWS_Resources(t *testing.T) {
|
||||||
{name: "App autoscaling scheduled action", dirName: "aws_appautoscaling_scheduled_action", wantErr: false},
|
{name: "App autoscaling scheduled action", dirName: "aws_appautoscaling_scheduled_action", wantErr: false},
|
||||||
{name: "App gateway v2 vpc link", dirName: "apigatewayv2_vpc_link", wantErr: false},
|
{name: "App gateway v2 vpc link", dirName: "apigatewayv2_vpc_link", wantErr: false},
|
||||||
{name: "Launch template", dirName: "aws_launch_template", wantErr: false},
|
{name: "Launch template", dirName: "aws_launch_template", wantErr: false},
|
||||||
|
{name: "Launch configuration", dirName: "aws_launch_configuration", wantErr: false},
|
||||||
}
|
}
|
||||||
for _, tt := range tests {
|
for _, tt := range tests {
|
||||||
t.Run(tt.name, func(t *testing.T) {
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
|
|
|
@ -0,0 +1,21 @@
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"Id": "web_config",
|
||||||
|
"Type": "aws_launch_configuration",
|
||||||
|
"Attrs": {
|
||||||
|
"arn": "arn:aws:autoscaling:us-east-1:533948124879:launchConfiguration:2cbee675-0d59-454b-866d-e9476e69381d:launchConfigurationName/web_config",
|
||||||
|
"associate_public_ip_address": false,
|
||||||
|
"ebs_optimized": false,
|
||||||
|
"enable_monitoring": true,
|
||||||
|
"iam_instance_profile": "",
|
||||||
|
"id": "web_config",
|
||||||
|
"image_id": "ami-022d4249382309a48",
|
||||||
|
"instance_type": "t3.micro",
|
||||||
|
"key_name": "",
|
||||||
|
"name": "web_config",
|
||||||
|
"name_prefix": "",
|
||||||
|
"spot_price": "",
|
||||||
|
"vpc_classic_link_id": ""
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,49 @@
|
||||||
|
{
|
||||||
|
"version": 4,
|
||||||
|
"terraform_version": "1.0.0",
|
||||||
|
"serial": 352,
|
||||||
|
"lineage": "9566e18d-6080-4aa8-e9a6-4c38905cf68f",
|
||||||
|
"outputs": {},
|
||||||
|
"resources": [
|
||||||
|
{
|
||||||
|
"mode": "managed",
|
||||||
|
"type": "aws_launch_configuration",
|
||||||
|
"name": "as_conf",
|
||||||
|
"provider": "provider[\"registry.terraform.io/hashicorp/aws\"]",
|
||||||
|
"instances": [
|
||||||
|
{
|
||||||
|
"schema_version": 0,
|
||||||
|
"attributes": {
|
||||||
|
"arn": "arn:aws:autoscaling:us-east-1:533948124879:launchConfiguration:2cbee675-0d59-454b-866d-e9476e69381d:launchConfigurationName/web_config",
|
||||||
|
"associate_public_ip_address": false,
|
||||||
|
"ebs_block_device": [],
|
||||||
|
"ebs_optimized": false,
|
||||||
|
"enable_monitoring": true,
|
||||||
|
"ephemeral_block_device": [],
|
||||||
|
"iam_instance_profile": "",
|
||||||
|
"id": "web_config",
|
||||||
|
"image_id": "ami-022d4249382309a48",
|
||||||
|
"instance_type": "t3.micro",
|
||||||
|
"key_name": "",
|
||||||
|
"metadata_options": [],
|
||||||
|
"name": "web_config",
|
||||||
|
"name_prefix": "",
|
||||||
|
"placement_tenancy": null,
|
||||||
|
"root_block_device": [],
|
||||||
|
"security_groups": null,
|
||||||
|
"spot_price": "",
|
||||||
|
"user_data": null,
|
||||||
|
"user_data_base64": null,
|
||||||
|
"vpc_classic_link_id": "",
|
||||||
|
"vpc_classic_link_security_groups": null
|
||||||
|
},
|
||||||
|
"sensitive_attributes": [],
|
||||||
|
"private": "bnVsbA==",
|
||||||
|
"dependencies": [
|
||||||
|
"data.aws_ami.ubuntu"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
|
@ -52,6 +52,7 @@ func Init(version string, alerter *alerter.Alerter,
|
||||||
apigatewayRepository := repository.NewApiGatewayRepository(provider.session, repositoryCache)
|
apigatewayRepository := repository.NewApiGatewayRepository(provider.session, repositoryCache)
|
||||||
appAutoScalingRepository := repository.NewAppAutoScalingRepository(provider.session, repositoryCache)
|
appAutoScalingRepository := repository.NewAppAutoScalingRepository(provider.session, repositoryCache)
|
||||||
apigatewayv2Repository := repository.NewApiGatewayV2Repository(provider.session, repositoryCache)
|
apigatewayv2Repository := repository.NewApiGatewayV2Repository(provider.session, repositoryCache)
|
||||||
|
autoscalingRepository := repository.NewAutoScalingRepository(provider.session, repositoryCache)
|
||||||
|
|
||||||
deserializer := resource.NewDeserializer(factory)
|
deserializer := resource.NewDeserializer(factory)
|
||||||
providerLibrary.AddProvider(terraform.AWS, provider)
|
providerLibrary.AddProvider(terraform.AWS, provider)
|
||||||
|
@ -216,6 +217,7 @@ func Init(version string, alerter *alerter.Alerter,
|
||||||
|
|
||||||
remoteLibrary.AddEnumerator(NewLaunchTemplateEnumerator(ec2repository, factory))
|
remoteLibrary.AddEnumerator(NewLaunchTemplateEnumerator(ec2repository, factory))
|
||||||
remoteLibrary.AddDetailsFetcher(aws.AwsLaunchTemplateResourceType, common.NewGenericDetailsFetcher(aws.AwsLaunchTemplateResourceType, provider, deserializer))
|
remoteLibrary.AddDetailsFetcher(aws.AwsLaunchTemplateResourceType, common.NewGenericDetailsFetcher(aws.AwsLaunchTemplateResourceType, provider, deserializer))
|
||||||
|
remoteLibrary.AddEnumerator(NewLaunchConfigurationEnumerator(autoscalingRepository, factory))
|
||||||
|
|
||||||
err = resourceSchemaRepository.Init(terraform.AWS, provider.Version(), provider.Schema())
|
err = resourceSchemaRepository.Init(terraform.AWS, provider.Version(), provider.Schema())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -0,0 +1,46 @@
|
||||||
|
package aws
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/snyk/driftctl/pkg/remote/aws/repository"
|
||||||
|
remoteerror "github.com/snyk/driftctl/pkg/remote/error"
|
||||||
|
"github.com/snyk/driftctl/pkg/resource"
|
||||||
|
"github.com/snyk/driftctl/pkg/resource/aws"
|
||||||
|
)
|
||||||
|
|
||||||
|
type LaunchConfigurationEnumerator struct {
|
||||||
|
repository repository.AutoScalingRepository
|
||||||
|
factory resource.ResourceFactory
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewLaunchConfigurationEnumerator(repo repository.AutoScalingRepository, factory resource.ResourceFactory) *LaunchConfigurationEnumerator {
|
||||||
|
return &LaunchConfigurationEnumerator{
|
||||||
|
repository: repo,
|
||||||
|
factory: factory,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (e *LaunchConfigurationEnumerator) SupportedType() resource.ResourceType {
|
||||||
|
return aws.AwsLaunchConfigurationResourceType
|
||||||
|
}
|
||||||
|
|
||||||
|
func (e *LaunchConfigurationEnumerator) Enumerate() ([]*resource.Resource, error) {
|
||||||
|
configs, err := e.repository.DescribeLaunchConfigurations()
|
||||||
|
if err != nil {
|
||||||
|
return nil, remoteerror.NewResourceListingError(err, string(e.SupportedType()))
|
||||||
|
}
|
||||||
|
|
||||||
|
results := make([]*resource.Resource, 0, len(configs))
|
||||||
|
|
||||||
|
for _, config := range configs {
|
||||||
|
results = append(
|
||||||
|
results,
|
||||||
|
e.factory.CreateAbstractResource(
|
||||||
|
string(e.SupportedType()),
|
||||||
|
*config.LaunchConfigurationName,
|
||||||
|
map[string]interface{}{},
|
||||||
|
),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
return results, err
|
||||||
|
}
|
|
@ -0,0 +1,44 @@
|
||||||
|
package repository
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/aws/aws-sdk-go/aws/session"
|
||||||
|
"github.com/aws/aws-sdk-go/service/autoscaling"
|
||||||
|
"github.com/aws/aws-sdk-go/service/autoscaling/autoscalingiface"
|
||||||
|
"github.com/snyk/driftctl/pkg/remote/cache"
|
||||||
|
)
|
||||||
|
|
||||||
|
type AutoScalingRepository interface {
|
||||||
|
DescribeLaunchConfigurations() ([]*autoscaling.LaunchConfiguration, error)
|
||||||
|
}
|
||||||
|
|
||||||
|
type autoScalingRepository struct {
|
||||||
|
client autoscalingiface.AutoScalingAPI
|
||||||
|
cache cache.Cache
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewAutoScalingRepository(session *session.Session, c cache.Cache) *autoScalingRepository {
|
||||||
|
return &autoScalingRepository{
|
||||||
|
autoscaling.New(session),
|
||||||
|
c,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (r *autoScalingRepository) DescribeLaunchConfigurations() ([]*autoscaling.LaunchConfiguration, error) {
|
||||||
|
cacheKey := "DescribeLaunchConfigurations"
|
||||||
|
if v := r.cache.Get(cacheKey); v != nil {
|
||||||
|
return v.([]*autoscaling.LaunchConfiguration), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
var results []*autoscaling.LaunchConfiguration
|
||||||
|
input := &autoscaling.DescribeLaunchConfigurationsInput{}
|
||||||
|
err := r.client.DescribeLaunchConfigurationsPages(input, func(resp *autoscaling.DescribeLaunchConfigurationsOutput, lastPage bool) bool {
|
||||||
|
results = append(results, resp.LaunchConfigurations...)
|
||||||
|
return !lastPage
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
r.cache.Put(cacheKey, results)
|
||||||
|
return results, nil
|
||||||
|
}
|
|
@ -0,0 +1,104 @@
|
||||||
|
package repository
|
||||||
|
|
||||||
|
import (
|
||||||
|
"errors"
|
||||||
|
"strings"
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"github.com/aws/aws-sdk-go/service/autoscaling"
|
||||||
|
"github.com/snyk/driftctl/pkg/remote/cache"
|
||||||
|
awstest "github.com/snyk/driftctl/test/aws"
|
||||||
|
"github.com/stretchr/testify/mock"
|
||||||
|
|
||||||
|
"github.com/aws/aws-sdk-go/aws"
|
||||||
|
|
||||||
|
"github.com/r3labs/diff/v2"
|
||||||
|
"github.com/stretchr/testify/assert"
|
||||||
|
)
|
||||||
|
|
||||||
|
func Test_AutoscalingRepository_DescribeLaunchConfigurations(t *testing.T) {
|
||||||
|
dummryError := errors.New("dummy error")
|
||||||
|
|
||||||
|
expectedLaunchConfigurations := []*autoscaling.LaunchConfiguration{
|
||||||
|
{ImageId: aws.String("1")},
|
||||||
|
{ImageId: aws.String("2")},
|
||||||
|
{ImageId: aws.String("3")},
|
||||||
|
{ImageId: aws.String("4")},
|
||||||
|
}
|
||||||
|
|
||||||
|
tests := []struct {
|
||||||
|
name string
|
||||||
|
mocks func(*awstest.MockFakeAutoscaling, *cache.MockCache)
|
||||||
|
want []*autoscaling.LaunchConfiguration
|
||||||
|
wantErr error
|
||||||
|
}{
|
||||||
|
{
|
||||||
|
name: "List all launch configurations",
|
||||||
|
mocks: func(client *awstest.MockFakeAutoscaling, store *cache.MockCache) {
|
||||||
|
store.On("Get", "DescribeLaunchConfigurations").Return(nil).Once()
|
||||||
|
|
||||||
|
client.On("DescribeLaunchConfigurationsPages",
|
||||||
|
&autoscaling.DescribeLaunchConfigurationsInput{},
|
||||||
|
mock.MatchedBy(func(callback func(res *autoscaling.DescribeLaunchConfigurationsOutput, lastPage bool) bool) bool {
|
||||||
|
callback(&autoscaling.DescribeLaunchConfigurationsOutput{
|
||||||
|
LaunchConfigurations: expectedLaunchConfigurations[:2],
|
||||||
|
}, false)
|
||||||
|
callback(&autoscaling.DescribeLaunchConfigurationsOutput{
|
||||||
|
LaunchConfigurations: expectedLaunchConfigurations[2:],
|
||||||
|
}, true)
|
||||||
|
return true
|
||||||
|
})).Return(nil).Once()
|
||||||
|
|
||||||
|
store.On("Put", "DescribeLaunchConfigurations", expectedLaunchConfigurations).Return(false).Once()
|
||||||
|
},
|
||||||
|
want: expectedLaunchConfigurations,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "Hit cache and list all launch configurations",
|
||||||
|
mocks: func(client *awstest.MockFakeAutoscaling, store *cache.MockCache) {
|
||||||
|
store.On("Get", "DescribeLaunchConfigurations").Return(expectedLaunchConfigurations).Once()
|
||||||
|
},
|
||||||
|
want: expectedLaunchConfigurations,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "Error listing all launch configurations",
|
||||||
|
mocks: func(client *awstest.MockFakeAutoscaling, store *cache.MockCache) {
|
||||||
|
store.On("Get", "DescribeLaunchConfigurations").Return(nil).Once()
|
||||||
|
|
||||||
|
client.On("DescribeLaunchConfigurationsPages", &autoscaling.DescribeLaunchConfigurationsInput{}, mock.MatchedBy(func(callback func(res *autoscaling.DescribeLaunchConfigurationsOutput, lastPage bool) bool) bool {
|
||||||
|
callback(&autoscaling.DescribeLaunchConfigurationsOutput{
|
||||||
|
LaunchConfigurations: []*autoscaling.LaunchConfiguration{},
|
||||||
|
}, true)
|
||||||
|
return true
|
||||||
|
})).Return(dummryError).Once()
|
||||||
|
},
|
||||||
|
want: nil,
|
||||||
|
wantErr: dummryError,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
for _, tt := range tests {
|
||||||
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
|
store := &cache.MockCache{}
|
||||||
|
client := &awstest.MockFakeAutoscaling{}
|
||||||
|
tt.mocks(client, store)
|
||||||
|
r := &autoScalingRepository{
|
||||||
|
client: client,
|
||||||
|
cache: store,
|
||||||
|
}
|
||||||
|
got, err := r.DescribeLaunchConfigurations()
|
||||||
|
assert.Equal(t, tt.wantErr, err)
|
||||||
|
|
||||||
|
changelog, err := diff.Diff(got, tt.want)
|
||||||
|
assert.Nil(t, err)
|
||||||
|
if len(changelog) > 0 {
|
||||||
|
for _, change := range changelog {
|
||||||
|
t.Errorf("%s: %s -> %s", strings.Join(change.Path, "."), change.From, change.To)
|
||||||
|
}
|
||||||
|
t.Fail()
|
||||||
|
}
|
||||||
|
|
||||||
|
store.AssertExpectations(t)
|
||||||
|
client.AssertExpectations(t)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,36 @@
|
||||||
|
// Code generated by mockery v2.8.0. DO NOT EDIT.
|
||||||
|
|
||||||
|
package repository
|
||||||
|
|
||||||
|
import (
|
||||||
|
autoscaling "github.com/aws/aws-sdk-go/service/autoscaling"
|
||||||
|
mock "github.com/stretchr/testify/mock"
|
||||||
|
)
|
||||||
|
|
||||||
|
// MockAutoScalingRepository is an autogenerated mock type for the AutoScalingRepository type
|
||||||
|
type MockAutoScalingRepository struct {
|
||||||
|
mock.Mock
|
||||||
|
}
|
||||||
|
|
||||||
|
// DescribeLaunchConfigurations provides a mock function with given fields:
|
||||||
|
func (_m *MockAutoScalingRepository) DescribeLaunchConfigurations() ([]*autoscaling.LaunchConfiguration, error) {
|
||||||
|
ret := _m.Called()
|
||||||
|
|
||||||
|
var r0 []*autoscaling.LaunchConfiguration
|
||||||
|
if rf, ok := ret.Get(0).(func() []*autoscaling.LaunchConfiguration); ok {
|
||||||
|
r0 = rf()
|
||||||
|
} else {
|
||||||
|
if ret.Get(0) != nil {
|
||||||
|
r0 = ret.Get(0).([]*autoscaling.LaunchConfiguration)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var r1 error
|
||||||
|
if rf, ok := ret.Get(1).(func() error); ok {
|
||||||
|
r1 = rf()
|
||||||
|
} else {
|
||||||
|
r1 = ret.Error(1)
|
||||||
|
}
|
||||||
|
|
||||||
|
return r0, r1
|
||||||
|
}
|
|
@ -0,0 +1,108 @@
|
||||||
|
package remote
|
||||||
|
|
||||||
|
import (
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
awssdk "github.com/aws/aws-sdk-go/aws"
|
||||||
|
"github.com/aws/aws-sdk-go/aws/awserr"
|
||||||
|
"github.com/aws/aws-sdk-go/service/autoscaling"
|
||||||
|
"github.com/pkg/errors"
|
||||||
|
"github.com/snyk/driftctl/mocks"
|
||||||
|
"github.com/snyk/driftctl/pkg/filter"
|
||||||
|
"github.com/snyk/driftctl/pkg/remote/alerts"
|
||||||
|
"github.com/snyk/driftctl/pkg/remote/aws"
|
||||||
|
"github.com/snyk/driftctl/pkg/remote/aws/repository"
|
||||||
|
"github.com/snyk/driftctl/pkg/remote/common"
|
||||||
|
remoteerr "github.com/snyk/driftctl/pkg/remote/error"
|
||||||
|
"github.com/snyk/driftctl/pkg/resource"
|
||||||
|
resourceaws "github.com/snyk/driftctl/pkg/resource/aws"
|
||||||
|
"github.com/snyk/driftctl/pkg/terraform"
|
||||||
|
testresource "github.com/snyk/driftctl/test/resource"
|
||||||
|
"github.com/stretchr/testify/assert"
|
||||||
|
"github.com/stretchr/testify/mock"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestAutoscaling_LaunchConfiguration(t *testing.T) {
|
||||||
|
tests := []struct {
|
||||||
|
test string
|
||||||
|
mocks func(*repository.MockAutoScalingRepository, *mocks.AlerterInterface)
|
||||||
|
assertExpected func(*testing.T, []*resource.Resource)
|
||||||
|
wantErr error
|
||||||
|
}{
|
||||||
|
{
|
||||||
|
test: "no launch configuration",
|
||||||
|
mocks: func(repository *repository.MockAutoScalingRepository, alerter *mocks.AlerterInterface) {
|
||||||
|
repository.On("DescribeLaunchConfigurations").Return([]*autoscaling.LaunchConfiguration{}, nil)
|
||||||
|
},
|
||||||
|
assertExpected: func(t *testing.T, got []*resource.Resource) {
|
||||||
|
assert.Len(t, got, 0)
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
test: "multiple launch configurations",
|
||||||
|
mocks: func(repository *repository.MockAutoScalingRepository, alerter *mocks.AlerterInterface) {
|
||||||
|
repository.On("DescribeLaunchConfigurations").Return([]*autoscaling.LaunchConfiguration{
|
||||||
|
{LaunchConfigurationName: awssdk.String("web_config_1")},
|
||||||
|
{LaunchConfigurationName: awssdk.String("web_config_2")},
|
||||||
|
}, nil)
|
||||||
|
},
|
||||||
|
assertExpected: func(t *testing.T, got []*resource.Resource) {
|
||||||
|
assert.Len(t, got, 2)
|
||||||
|
|
||||||
|
assert.Equal(t, "web_config_1", got[0].ResourceId())
|
||||||
|
assert.Equal(t, resourceaws.AwsLaunchConfigurationResourceType, got[0].ResourceType())
|
||||||
|
|
||||||
|
assert.Equal(t, "web_config_2", got[1].ResourceId())
|
||||||
|
assert.Equal(t, resourceaws.AwsLaunchConfigurationResourceType, got[1].ResourceType())
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
test: "cannot list launch configurations",
|
||||||
|
mocks: func(repository *repository.MockAutoScalingRepository, alerter *mocks.AlerterInterface) {
|
||||||
|
awsError := awserr.NewRequestFailure(awserr.New("AccessDeniedException", "", errors.New("")), 403, "")
|
||||||
|
repository.On("DescribeLaunchConfigurations").Return(nil, awsError)
|
||||||
|
|
||||||
|
alerter.On("SendAlert", resourceaws.AwsLaunchConfigurationResourceType, alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, resourceaws.AwsLaunchConfigurationResourceType, resourceaws.AwsLaunchConfigurationResourceType), alerts.EnumerationPhase)).Return()
|
||||||
|
},
|
||||||
|
assertExpected: func(t *testing.T, got []*resource.Resource) {
|
||||||
|
assert.Len(t, got, 0)
|
||||||
|
},
|
||||||
|
wantErr: nil,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
schemaRepository := testresource.InitFakeSchemaRepository("aws", "3.19.0")
|
||||||
|
resourceaws.InitResourcesMetadata(schemaRepository)
|
||||||
|
factory := terraform.NewTerraformResourceFactory(schemaRepository)
|
||||||
|
|
||||||
|
for _, c := range tests {
|
||||||
|
t.Run(c.test, func(tt *testing.T) {
|
||||||
|
|
||||||
|
scanOptions := ScannerOptions{}
|
||||||
|
remoteLibrary := common.NewRemoteLibrary()
|
||||||
|
|
||||||
|
// Initialize mocks
|
||||||
|
alerter := &mocks.AlerterInterface{}
|
||||||
|
fakeRepo := &repository.MockAutoScalingRepository{}
|
||||||
|
c.mocks(fakeRepo, alerter)
|
||||||
|
|
||||||
|
var repo repository.AutoScalingRepository = fakeRepo
|
||||||
|
|
||||||
|
remoteLibrary.AddEnumerator(aws.NewLaunchConfigurationEnumerator(repo, factory))
|
||||||
|
|
||||||
|
testFilter := &filter.MockFilter{}
|
||||||
|
testFilter.On("IsTypeIgnored", mock.Anything).Return(false)
|
||||||
|
|
||||||
|
s := NewScanner(remoteLibrary, alerter, scanOptions, testFilter)
|
||||||
|
got, err := s.Resources()
|
||||||
|
assert.Equal(tt, c.wantErr, err)
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
c.assertExpected(tt, got)
|
||||||
|
alerter.AssertExpectations(tt)
|
||||||
|
fakeRepo.AssertExpectations(tt)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,3 @@
|
||||||
|
package aws
|
||||||
|
|
||||||
|
const AwsLaunchConfigurationResourceType = "aws_launch_configuration"
|
|
@ -0,0 +1,30 @@
|
||||||
|
package aws_test
|
||||||
|
|
||||||
|
import (
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"github.com/snyk/driftctl/test"
|
||||||
|
"github.com/snyk/driftctl/test/acceptance"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestAcc_AwsLaunchConfiguration(t *testing.T) {
|
||||||
|
acceptance.Run(t, acceptance.AccTestCase{
|
||||||
|
TerraformVersion: "0.15.5",
|
||||||
|
Paths: []string{"./testdata/acc/aws_launch_configuration"},
|
||||||
|
Args: []string{"scan"},
|
||||||
|
Checks: []acceptance.AccCheck{
|
||||||
|
{
|
||||||
|
Env: map[string]string{
|
||||||
|
"AWS_REGION": "us-east-1",
|
||||||
|
},
|
||||||
|
Check: func(result *test.ScanResult, stdout string, err error) {
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
result.AssertInfrastructureIsInSync()
|
||||||
|
result.AssertManagedCount(1)
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
|
@ -95,6 +95,7 @@ func TestAWS_Metadata_Flags(t *testing.T) {
|
||||||
AwsSecurityGroupRuleResourceType: {resource.FlagDeepMode},
|
AwsSecurityGroupRuleResourceType: {resource.FlagDeepMode},
|
||||||
AwsNetworkACLRuleResourceType: {resource.FlagDeepMode},
|
AwsNetworkACLRuleResourceType: {resource.FlagDeepMode},
|
||||||
AwsLaunchTemplateResourceType: {resource.FlagDeepMode},
|
AwsLaunchTemplateResourceType: {resource.FlagDeepMode},
|
||||||
|
AwsLaunchConfigurationResourceType: {},
|
||||||
}
|
}
|
||||||
|
|
||||||
schemaRepository := testresource.InitFakeSchemaRepository(tf.AWS, "3.19.0")
|
schemaRepository := testresource.InitFakeSchemaRepository(tf.AWS, "3.19.0")
|
||||||
|
|
|
@ -0,0 +1,2 @@
|
||||||
|
*
|
||||||
|
!aws_launch_configuration
|
|
@ -0,0 +1,21 @@
|
||||||
|
# This file is maintained automatically by "terraform init".
|
||||||
|
# Manual edits may be lost in future updates.
|
||||||
|
|
||||||
|
provider "registry.terraform.io/hashicorp/aws" {
|
||||||
|
version = "3.19.0"
|
||||||
|
constraints = "3.19.0"
|
||||||
|
hashes = [
|
||||||
|
"h1:+7Vi7p13+cnrxjXbfJiTimGSFR97xCaQwkkvWcreLns=",
|
||||||
|
"h1:xur9tF49NgsovNnmwmBR8RdpN8Fcg1TD4CKQPJD6n1A=",
|
||||||
|
"zh:185a5259153eb9ee4699d4be43b3d509386b473683392034319beee97d470c3b",
|
||||||
|
"zh:2d9a0a01f93e8d16539d835c02b8b6e1927b7685f4076e96cb07f7dd6944bc6c",
|
||||||
|
"zh:703f6da36b1b5f3497baa38fccaa7765fb8a2b6440344e4c97172516b49437dd",
|
||||||
|
"zh:770855565462abadbbddd98cb357d2f1a8f30f68a358cb37cbd5c072cb15b377",
|
||||||
|
"zh:8008db43149fe4345301f81e15e6d9ddb47aa5e7a31648f9b290af96ad86e92a",
|
||||||
|
"zh:8cdd27d375da6dcb7687f1fed126b7c04efce1671066802ee876dbbc9c66ec79",
|
||||||
|
"zh:be22ae185005690d1a017c1b909e0d80ab567e239b4f06ecacdba85080667c1c",
|
||||||
|
"zh:d2d02e72dbd80f607636cd6237a6c862897caabc635c7b50c0cb243d11246723",
|
||||||
|
"zh:d8f125b66a1eda2555c0f9bbdf12036a5f8d073499a22ca9e4812b68067fea31",
|
||||||
|
"zh:f5a98024c64d5d2973ff15b093725a074c0cb4afde07ef32c542e69f17ac90bc",
|
||||||
|
]
|
||||||
|
}
|
|
@ -0,0 +1,31 @@
|
||||||
|
provider "aws" {
|
||||||
|
region = "us-east-1"
|
||||||
|
}
|
||||||
|
|
||||||
|
terraform {
|
||||||
|
required_providers {
|
||||||
|
aws = "3.19.0"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
data "aws_ami" "ubuntu" {
|
||||||
|
most_recent = true
|
||||||
|
|
||||||
|
filter {
|
||||||
|
name = "name"
|
||||||
|
values = ["ubuntu/images/hvm-ssd/ubuntu-focal-20.04-amd64-server-*"]
|
||||||
|
}
|
||||||
|
|
||||||
|
filter {
|
||||||
|
name = "virtualization-type"
|
||||||
|
values = ["hvm"]
|
||||||
|
}
|
||||||
|
|
||||||
|
owners = ["099720109477"] # Canonical
|
||||||
|
}
|
||||||
|
|
||||||
|
resource "aws_launch_configuration" "as_conf" {
|
||||||
|
name = "web_config"
|
||||||
|
image_id = data.aws_ami.ubuntu.id
|
||||||
|
instance_type = "t3.micro"
|
||||||
|
}
|
|
@ -143,6 +143,7 @@ var supportedTypes = map[string]ResourceTypeMeta{
|
||||||
"aws_apigatewayv2_vpc_link": {},
|
"aws_apigatewayv2_vpc_link": {},
|
||||||
"aws_apigatewayv2_authorizer": {},
|
"aws_apigatewayv2_authorizer": {},
|
||||||
"aws_launch_template": {},
|
"aws_launch_template": {},
|
||||||
|
"aws_launch_configuration": {},
|
||||||
|
|
||||||
"github_branch_protection": {},
|
"github_branch_protection": {},
|
||||||
"github_membership": {},
|
"github_membership": {},
|
||||||
|
|
|
@ -0,0 +1,9 @@
|
||||||
|
package aws
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/aws/aws-sdk-go/service/autoscaling/autoscalingiface"
|
||||||
|
)
|
||||||
|
|
||||||
|
type FakeAutoscaling interface {
|
||||||
|
autoscalingiface.AutoScalingAPI
|
||||||
|
}
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue