feat: add aws_launch_configuration
parent
db6e8922dd
commit
5079c9b315
|
@ -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 gateway v2 vpc link", dirName: "apigatewayv2_vpc_link", wantErr: false},
|
||||
{name: "Launch template", dirName: "aws_launch_template", wantErr: false},
|
||||
{name: "Launch configuration", dirName: "aws_launch_configuration", wantErr: false},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
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)
|
||||
appAutoScalingRepository := repository.NewAppAutoScalingRepository(provider.session, repositoryCache)
|
||||
apigatewayv2Repository := repository.NewApiGatewayV2Repository(provider.session, repositoryCache)
|
||||
autoscalingRepository := repository.NewAutoScalingRepository(provider.session, repositoryCache)
|
||||
|
||||
deserializer := resource.NewDeserializer(factory)
|
||||
providerLibrary.AddProvider(terraform.AWS, provider)
|
||||
|
@ -216,6 +217,8 @@ func Init(version string, alerter *alerter.Alerter,
|
|||
|
||||
remoteLibrary.AddEnumerator(NewLaunchTemplateEnumerator(ec2repository, factory))
|
||||
remoteLibrary.AddDetailsFetcher(aws.AwsLaunchTemplateResourceType, common.NewGenericDetailsFetcher(aws.AwsLaunchTemplateResourceType, provider, deserializer))
|
||||
remoteLibrary.AddEnumerator(NewLaunchConfigurationEnumerator(autoscalingRepository, factory))
|
||||
remoteLibrary.AddDetailsFetcher(aws.AwsLaunchConfigurationResourceType, common.NewGenericDetailsFetcher(aws.AwsLaunchConfigurationResourceType, provider, deserializer))
|
||||
|
||||
err = resourceSchemaRepository.Init(terraform.AWS, provider.Version(), provider.Schema())
|
||||
if err != nil {
|
||||
|
|
|
@ -0,0 +1,46 @@
|
|||
package aws
|
||||
|
||||
import (
|
||||
"github.com/cloudskiff/driftctl/pkg/remote/aws/repository"
|
||||
remoteerror "github.com/cloudskiff/driftctl/pkg/remote/error"
|
||||
"github.com/cloudskiff/driftctl/pkg/resource"
|
||||
"github.com/cloudskiff/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,40 @@
|
|||
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/cloudskiff/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
|
||||
}
|
||||
|
||||
input := &autoscaling.DescribeLaunchConfigurationsInput{}
|
||||
result, err := r.client.DescribeLaunchConfigurations(input)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
r.cache.Put(cacheKey, result.LaunchConfigurations)
|
||||
return result.LaunchConfigurations, nil
|
||||
}
|
|
@ -0,0 +1,87 @@
|
|||
package repository
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/aws/aws-sdk-go/service/autoscaling"
|
||||
"github.com/cloudskiff/driftctl/pkg/remote/cache"
|
||||
awstest "github.com/cloudskiff/driftctl/test/aws"
|
||||
|
||||
"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")
|
||||
|
||||
tests := []struct {
|
||||
name string
|
||||
mocks func(client *awstest.MockFakeAutoscaling)
|
||||
want []*autoscaling.LaunchConfiguration
|
||||
wantErr error
|
||||
}{
|
||||
{
|
||||
name: "List all launch configurations",
|
||||
mocks: func(client *awstest.MockFakeAutoscaling) {
|
||||
client.On("DescribeLaunchConfigurations",
|
||||
&autoscaling.DescribeLaunchConfigurationsInput{}).Return(&autoscaling.DescribeLaunchConfigurationsOutput{
|
||||
LaunchConfigurations: []*autoscaling.LaunchConfiguration{
|
||||
{ImageId: aws.String("1")},
|
||||
{ImageId: aws.String("2")},
|
||||
{ImageId: aws.String("3")},
|
||||
{ImageId: aws.String("4")},
|
||||
},
|
||||
}, nil).Once()
|
||||
},
|
||||
want: []*autoscaling.LaunchConfiguration{
|
||||
{ImageId: aws.String("1")},
|
||||
{ImageId: aws.String("2")},
|
||||
{ImageId: aws.String("3")},
|
||||
{ImageId: aws.String("4")},
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "Error listing all launch configurations",
|
||||
mocks: func(client *awstest.MockFakeAutoscaling) {
|
||||
client.On("DescribeLaunchConfigurations",
|
||||
&autoscaling.DescribeLaunchConfigurationsInput{}).Return(nil, dummryError).Once()
|
||||
},
|
||||
want: nil,
|
||||
wantErr: dummryError,
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
store := cache.New(1)
|
||||
client := &awstest.MockFakeAutoscaling{}
|
||||
tt.mocks(client)
|
||||
r := &autoScalingRepository{
|
||||
client: client,
|
||||
cache: store,
|
||||
}
|
||||
got, err := r.DescribeLaunchConfigurations()
|
||||
assert.Equal(t, tt.wantErr, err)
|
||||
|
||||
if err == nil {
|
||||
// Check that results were cached
|
||||
cachedData, err := r.DescribeLaunchConfigurations()
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, got, cachedData)
|
||||
assert.IsType(t, []*autoscaling.LaunchConfiguration{}, store.Get("DescribeLaunchConfigurations"))
|
||||
}
|
||||
|
||||
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()
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
|
@ -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,126 @@
|
|||
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/aws/session"
|
||||
"github.com/aws/aws-sdk-go/service/autoscaling"
|
||||
"github.com/cloudskiff/driftctl/mocks"
|
||||
"github.com/cloudskiff/driftctl/pkg/filter"
|
||||
"github.com/cloudskiff/driftctl/pkg/remote/alerts"
|
||||
"github.com/cloudskiff/driftctl/pkg/remote/aws"
|
||||
"github.com/cloudskiff/driftctl/pkg/remote/aws/repository"
|
||||
"github.com/cloudskiff/driftctl/pkg/remote/cache"
|
||||
"github.com/cloudskiff/driftctl/pkg/remote/common"
|
||||
remoteerr "github.com/cloudskiff/driftctl/pkg/remote/error"
|
||||
"github.com/cloudskiff/driftctl/pkg/resource"
|
||||
resourceaws "github.com/cloudskiff/driftctl/pkg/resource/aws"
|
||||
"github.com/cloudskiff/driftctl/pkg/terraform"
|
||||
"github.com/cloudskiff/driftctl/test"
|
||||
"github.com/cloudskiff/driftctl/test/goldenfile"
|
||||
testresource "github.com/cloudskiff/driftctl/test/resource"
|
||||
terraformtest "github.com/cloudskiff/driftctl/test/terraform"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/mock"
|
||||
)
|
||||
|
||||
func TestAutoscaling_LaunchConfiguration(t *testing.T) {
|
||||
tests := []struct {
|
||||
test string
|
||||
dirName string
|
||||
mocks func(*repository.MockAutoScalingRepository, *mocks.AlerterInterface)
|
||||
wantErr error
|
||||
}{
|
||||
{
|
||||
test: "no launch configuration",
|
||||
dirName: "aws_launch_configuration",
|
||||
mocks: func(repository *repository.MockAutoScalingRepository, alerter *mocks.AlerterInterface) {
|
||||
repository.On("DescribeLaunchConfigurations").Return([]*autoscaling.LaunchConfiguration{}, nil)
|
||||
},
|
||||
},
|
||||
{
|
||||
test: "multiple launch configurations",
|
||||
dirName: "aws_launch_configuration_multiple",
|
||||
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)
|
||||
},
|
||||
},
|
||||
{
|
||||
test: "cannot list launch configurations",
|
||||
dirName: "aws_launch_configuration",
|
||||
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()
|
||||
},
|
||||
wantErr: nil,
|
||||
},
|
||||
}
|
||||
|
||||
schemaRepository := testresource.InitFakeSchemaRepository("aws", "3.19.0")
|
||||
resourceaws.InitResourcesMetadata(schemaRepository)
|
||||
factory := terraform.NewTerraformResourceFactory(schemaRepository)
|
||||
deserializer := resource.NewDeserializer(factory)
|
||||
|
||||
for _, c := range tests {
|
||||
t.Run(c.test, func(tt *testing.T) {
|
||||
shouldUpdate := c.dirName == *goldenfile.Update
|
||||
|
||||
sess := session.Must(session.NewSessionWithOptions(session.Options{
|
||||
SharedConfigState: session.SharedConfigEnable,
|
||||
}))
|
||||
|
||||
scanOptions := ScannerOptions{Deep: true}
|
||||
providerLibrary := terraform.NewProviderLibrary()
|
||||
remoteLibrary := common.NewRemoteLibrary()
|
||||
|
||||
// Initialize mocks
|
||||
alerter := &mocks.AlerterInterface{}
|
||||
fakeRepo := &repository.MockAutoScalingRepository{}
|
||||
c.mocks(fakeRepo, alerter)
|
||||
|
||||
var repo repository.AutoScalingRepository = fakeRepo
|
||||
providerVersion := "3.19.0"
|
||||
realProvider, err := terraformtest.InitTestAwsProvider(providerLibrary, providerVersion)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
provider := terraformtest.NewFakeTerraformProvider(realProvider)
|
||||
provider.WithResponse(c.dirName)
|
||||
|
||||
// Replace mock by real resources if we are in update mode
|
||||
if shouldUpdate {
|
||||
err := realProvider.Init()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
provider.ShouldUpdate()
|
||||
repo = repository.NewAutoScalingRepository(sess, cache.New(0))
|
||||
}
|
||||
|
||||
remoteLibrary.AddEnumerator(aws.NewLaunchConfigurationEnumerator(repo, factory))
|
||||
remoteLibrary.AddDetailsFetcher(resourceaws.AwsLaunchConfigurationResourceType, common.NewGenericDetailsFetcher(resourceaws.AwsLaunchConfigurationResourceType, provider, deserializer))
|
||||
|
||||
testFilter := &filter.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
|
||||
}
|
||||
test.TestAgainstGoldenFile(got, resourceaws.AwsLaunchConfigurationResourceType, c.dirName, provider, deserializer, shouldUpdate, tt)
|
||||
alerter.AssertExpectations(tt)
|
||||
fakeRepo.AssertExpectations(tt)
|
||||
testFilter.AssertExpectations(tt)
|
||||
})
|
||||
}
|
||||
}
|
|
@ -0,0 +1,5 @@
|
|||
{
|
||||
"Typ": "WyJvYmplY3QiLHsiYXJuIjoic3RyaW5nIiwiYXNzb2NpYXRlX3B1YmxpY19pcF9hZGRyZXNzIjoiYm9vbCIsImVic19ibG9ja19kZXZpY2UiOlsic2V0IixbIm9iamVjdCIseyJkZWxldGVfb25fdGVybWluYXRpb24iOiJib29sIiwiZGV2aWNlX25hbWUiOiJzdHJpbmciLCJlbmNyeXB0ZWQiOiJib29sIiwiaW9wcyI6Im51bWJlciIsIm5vX2RldmljZSI6ImJvb2wiLCJzbmFwc2hvdF9pZCI6InN0cmluZyIsInZvbHVtZV9zaXplIjoibnVtYmVyIiwidm9sdW1lX3R5cGUiOiJzdHJpbmcifV1dLCJlYnNfb3B0aW1pemVkIjoiYm9vbCIsImVuYWJsZV9tb25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hZGRyZXNzIjpmYWxzZSwiZWJzX2Jsb2NrX2RldmljZSI6W10sImVic19vcHRpbWl6ZWQiOmZhbHNlLCJlbmFibGVfbW9uaXRvcmluZyI6dHJ1ZSwiZXBoZW1lcmFsX2Jsb2NrX2RldmljZSI6W10sImlhbV9pbnN0YW5jZV9wcm9maWxlIjoiIiwiaWQiOiJ3ZWJfY29uZmlnXzIiLCJpbWFnZV9pZCI6ImFtaS0wMjJkNDI0OTM4MjMwOWE0OCIsImluc3RhbmNlX3R5cGUiOiJ0My5taWNybyIsImtleV9uYW1lIjoiIiwibmFtZSI6IndlYl9jb25maWdfMiIsIm5hbWVfcHJlZml4IjpudWxsLCJwbGFjZW1lbnRfdGVuYW5jeSI6bnVsbCwicm9vdF9ibG9ja19kZXZpY2UiOltdLCJzZWN1cml0eV9ncm91cHMiOltdLCJzcG90X3ByaWNlIjoiIiwidXNlcl9kYXRhIjpudWxsLCJ1c2VyX2RhdGFfYmFzZTY0IjpudWxsLCJ2cGNfY2xhc3NpY19saW5rX2lkIjoiIiwidnBjX2NsYXNzaWNfbGlua19zZWN1cml0eV9ncm91cHMiOltdfQ==",
|
||||
"Err": null
|
||||
}
|
|
@ -0,0 +1,48 @@
|
|||
[
|
||||
{
|
||||
"arn": "arn:aws:autoscaling:us-east-1:533948124879:launchConfiguration:68a3adcb-e21b-41d4-ae8b-72438e545169:launchConfigurationName/web_config_2",
|
||||
"associate_public_ip_address": false,
|
||||
"ebs_block_device": null,
|
||||
"ebs_optimized": false,
|
||||
"enable_monitoring": true,
|
||||
"ephemeral_block_device": null,
|
||||
"iam_instance_profile": "",
|
||||
"id": "web_config_2",
|
||||
"image_id": "ami-022d4249382309a48",
|
||||
"instance_type": "t3.micro",
|
||||
"key_name": "",
|
||||
"name": "web_config_2",
|
||||
"name_prefix": null,
|
||||
"placement_tenancy": null,
|
||||
"root_block_device": null,
|
||||
"security_groups": null,
|
||||
"spot_price": "",
|
||||
"user_data": null,
|
||||
"user_data_base64": null,
|
||||
"vpc_classic_link_id": "",
|
||||
"vpc_classic_link_security_groups": null
|
||||
},
|
||||
{
|
||||
"arn": "arn:aws:autoscaling:us-east-1:533948124879:launchConfiguration:6c6f7b4f-9009-41f4-bfbf-2e2c37321bff:launchConfigurationName/web_config_1",
|
||||
"associate_public_ip_address": false,
|
||||
"ebs_block_device": null,
|
||||
"ebs_optimized": false,
|
||||
"enable_monitoring": true,
|
||||
"ephemeral_block_device": null,
|
||||
"iam_instance_profile": "",
|
||||
"id": "web_config_1",
|
||||
"image_id": "ami-022d4249382309a48",
|
||||
"instance_type": "t3.micro",
|
||||
"key_name": "",
|
||||
"name": "web_config_1",
|
||||
"name_prefix": null,
|
||||
"placement_tenancy": null,
|
||||
"root_block_device": null,
|
||||
"security_groups": null,
|
||||
"spot_price": "",
|
||||
"user_data": null,
|
||||
"user_data_base64": null,
|
||||
"vpc_classic_link_id": "",
|
||||
"vpc_classic_link_security_groups": null
|
||||
}
|
||||
]
|
|
@ -0,0 +1,9 @@
|
|||
package aws
|
||||
|
||||
import "github.com/cloudskiff/driftctl/pkg/resource"
|
||||
|
||||
const AwsLaunchConfigurationResourceType = "aws_launch_configuration"
|
||||
|
||||
func initAwsLaunchConfigurationMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) {
|
||||
resourceSchemaRepository.SetFlags(AwsLaunchConfigurationResourceType, resource.FlagDeepMode)
|
||||
}
|
|
@ -0,0 +1,30 @@
|
|||
package aws_test
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/cloudskiff/driftctl/test"
|
||||
"github.com/cloudskiff/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", "--deep"},
|
||||
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},
|
||||
AwsNetworkACLRuleResourceType: {resource.FlagDeepMode},
|
||||
AwsLaunchTemplateResourceType: {resource.FlagDeepMode},
|
||||
AwsLaunchConfigurationResourceType: {resource.FlagDeepMode},
|
||||
}
|
||||
|
||||
schemaRepository := testresource.InitFakeSchemaRepository(tf.AWS, "3.19.0")
|
||||
|
|
|
@ -63,4 +63,5 @@ func InitResourcesMetadata(resourceSchemaRepository resource.SchemaRepositoryInt
|
|||
initAwsAppAutoscalingTargetMetaData(resourceSchemaRepository)
|
||||
initAwsAppAutoscalingPolicyMetaData(resourceSchemaRepository)
|
||||
initAwsLaunchTemplateMetaData(resourceSchemaRepository)
|
||||
initAwsLaunchConfigurationMetaData(resourceSchemaRepository)
|
||||
}
|
||||
|
|
|
@ -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_authorizer": {},
|
||||
"aws_launch_template": {},
|
||||
"aws_launch_configuration": {},
|
||||
|
||||
"github_branch_protection": {},
|
||||
"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