Merge pull request #1180 from cloudskiff/res/api_gtw_method_integration
Add aws_api_gateway_integration resourcemain
commit
a7b85c1540
|
@ -167,6 +167,7 @@ func TestTerraformStateReader_AWS_Resources(t *testing.T) {
|
|||
{name: "Api Gateway method response", dirName: "api_gateway_method_response", wantErr: false},
|
||||
{name: "Api Gateway gateway response", dirName: "api_gateway_gateway_response", wantErr: false},
|
||||
{name: "Api Gateway method settings", dirName: "api_gateway_method_settings", wantErr: false},
|
||||
{name: "Api Gateway integration", dirName: "api_gateway_integration", wantErr: false},
|
||||
{name: "AppAutoScaling Targets", dirName: "aws_appautoscaling_target", wantErr: false},
|
||||
{name: "network acl", dirName: "aws_network_acl", wantErr: false},
|
||||
{name: "network acl rule", dirName: "aws_network_acl_rule", wantErr: false},
|
||||
|
|
|
@ -0,0 +1,22 @@
|
|||
[
|
||||
{
|
||||
"Id": "agi-u7jce3lokk-z9ag20-GET",
|
||||
"Type": "aws_api_gateway_integration",
|
||||
"Attrs": {
|
||||
"cache_namespace": "z9ag20",
|
||||
"connection_id": "",
|
||||
"connection_type": "INTERNET",
|
||||
"content_handling": "",
|
||||
"credentials": "",
|
||||
"http_method": "GET",
|
||||
"id": "agi-u7jce3lokk-z9ag20-GET",
|
||||
"integration_http_method": "",
|
||||
"passthrough_behavior": "WHEN_NO_MATCH",
|
||||
"resource_id": "z9ag20",
|
||||
"rest_api_id": "u7jce3lokk",
|
||||
"timeout_milliseconds": 29000,
|
||||
"type": "MOCK",
|
||||
"uri": ""
|
||||
}
|
||||
}
|
||||
]
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,47 @@
|
|||
{
|
||||
"version": 4,
|
||||
"terraform_version": "1.0.9",
|
||||
"serial": 369,
|
||||
"lineage": "85f5bee6-139e-8db2-ae5d-82aa82f62611",
|
||||
"outputs": {},
|
||||
"resources": [
|
||||
{
|
||||
"mode": "managed",
|
||||
"type": "aws_api_gateway_integration",
|
||||
"name": "foo",
|
||||
"provider": "provider[\"registry.terraform.io/hashicorp/aws\"]",
|
||||
"instances": [
|
||||
{
|
||||
"schema_version": 0,
|
||||
"attributes": {
|
||||
"cache_key_parameters": [],
|
||||
"cache_namespace": "z9ag20",
|
||||
"connection_id": "",
|
||||
"connection_type": "INTERNET",
|
||||
"content_handling": "",
|
||||
"credentials": "",
|
||||
"http_method": "GET",
|
||||
"id": "agi-u7jce3lokk-z9ag20-GET",
|
||||
"integration_http_method": "",
|
||||
"passthrough_behavior": "WHEN_NO_MATCH",
|
||||
"request_parameters": {},
|
||||
"request_templates": {},
|
||||
"resource_id": "z9ag20",
|
||||
"rest_api_id": "u7jce3lokk",
|
||||
"timeout_milliseconds": 29000,
|
||||
"tls_config": [],
|
||||
"type": "MOCK",
|
||||
"uri": ""
|
||||
},
|
||||
"sensitive_attributes": [],
|
||||
"private": "bnVsbA==",
|
||||
"dependencies": [
|
||||
"aws_api_gateway_method.foo",
|
||||
"aws_api_gateway_resource.foo",
|
||||
"aws_api_gateway_rest_api.foo"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
|
@ -82,6 +82,7 @@ func (m *AwsApiGatewayRestApiExpander) handleBodyV3(apiId string, doc *openapi3.
|
|||
for statusCode := range method.Responses {
|
||||
m.createApiGatewayMethodResponse(apiId, res.ResourceId(), httpMethod, statusCode, results)
|
||||
}
|
||||
m.createApiGatewayIntegration(apiId, res.ResourceId(), httpMethod, results)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -100,6 +101,7 @@ func (m *AwsApiGatewayRestApiExpander) handleBodyV2(apiId string, doc *openapi2.
|
|||
for statusCode := range method.Responses {
|
||||
m.createApiGatewayMethodResponse(apiId, res.ResourceId(), httpMethod, statusCode, results)
|
||||
}
|
||||
m.createApiGatewayIntegration(apiId, res.ResourceId(), httpMethod, results)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -196,3 +198,13 @@ func decodeExtensions(extensions map[string]interface{}) (*OpenAPIAwsExtensions,
|
|||
}
|
||||
return decodedExtensions, nil
|
||||
}
|
||||
|
||||
// Create aws_api_gateway_integration resource
|
||||
func (m *AwsApiGatewayRestApiExpander) createApiGatewayIntegration(apiId, resourceId, httpMethod string, results *[]*resource.Resource) {
|
||||
newResource := m.resourceFactory.CreateAbstractResource(
|
||||
aws.AwsApiGatewayIntegrationResourceType,
|
||||
strings.Join([]string{"agi", apiId, resourceId, httpMethod}, "-"),
|
||||
map[string]interface{}{},
|
||||
)
|
||||
*results = append(*results, newResource)
|
||||
}
|
||||
|
|
|
@ -85,6 +85,26 @@ func TestAwsApiGatewayRestApiExpander_Execute(t *testing.T) {
|
|||
Type: aws.AwsApiGatewayMethodResponseResourceType,
|
||||
Attrs: &resource.Attributes{},
|
||||
})
|
||||
factory.On(
|
||||
"CreateAbstractResource",
|
||||
aws.AwsApiGatewayIntegrationResourceType,
|
||||
"agi-foo-bar-GET",
|
||||
map[string]interface{}{},
|
||||
).Once().Return(&resource.Resource{
|
||||
Id: "agi-foo-bar-GET",
|
||||
Type: aws.AwsApiGatewayIntegrationResourceType,
|
||||
Attrs: &resource.Attributes{},
|
||||
})
|
||||
factory.On(
|
||||
"CreateAbstractResource",
|
||||
aws.AwsApiGatewayIntegrationResourceType,
|
||||
"agi-foo-baz-GET",
|
||||
map[string]interface{}{},
|
||||
).Once().Return(&resource.Resource{
|
||||
Id: "agi-foo-baz-GET",
|
||||
Type: aws.AwsApiGatewayIntegrationResourceType,
|
||||
Attrs: &resource.Attributes{},
|
||||
})
|
||||
},
|
||||
resourcesFromState: []*resource.Resource{
|
||||
{
|
||||
|
@ -127,6 +147,16 @@ func TestAwsApiGatewayRestApiExpander_Execute(t *testing.T) {
|
|||
Type: aws.AwsApiGatewayMethodResponseResourceType,
|
||||
Attrs: &resource.Attributes{},
|
||||
},
|
||||
{
|
||||
Id: "agi-foo-bar-GET",
|
||||
Type: aws.AwsApiGatewayIntegrationResourceType,
|
||||
Attrs: &resource.Attributes{},
|
||||
},
|
||||
{
|
||||
Id: "agi-foo-baz-GET",
|
||||
Type: aws.AwsApiGatewayIntegrationResourceType,
|
||||
Attrs: &resource.Attributes{},
|
||||
},
|
||||
},
|
||||
expected: []*resource.Resource{
|
||||
{
|
||||
|
@ -167,6 +197,16 @@ func TestAwsApiGatewayRestApiExpander_Execute(t *testing.T) {
|
|||
Type: aws.AwsApiGatewayMethodResponseResourceType,
|
||||
Attrs: &resource.Attributes{},
|
||||
},
|
||||
{
|
||||
Id: "agi-foo-bar-GET",
|
||||
Type: aws.AwsApiGatewayIntegrationResourceType,
|
||||
Attrs: &resource.Attributes{},
|
||||
},
|
||||
{
|
||||
Id: "agi-foo-baz-GET",
|
||||
Type: aws.AwsApiGatewayIntegrationResourceType,
|
||||
Attrs: &resource.Attributes{},
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
|
@ -208,6 +248,16 @@ func TestAwsApiGatewayRestApiExpander_Execute(t *testing.T) {
|
|||
Type: aws.AwsApiGatewayMethodResponseResourceType,
|
||||
Attrs: &resource.Attributes{},
|
||||
})
|
||||
factory.On(
|
||||
"CreateAbstractResource",
|
||||
aws.AwsApiGatewayIntegrationResourceType,
|
||||
"agi-foo-bar-GET",
|
||||
map[string]interface{}{},
|
||||
).Once().Return(&resource.Resource{
|
||||
Id: "agi-foo-bar-GET",
|
||||
Type: aws.AwsApiGatewayIntegrationResourceType,
|
||||
Attrs: &resource.Attributes{},
|
||||
})
|
||||
},
|
||||
resourcesFromState: []*resource.Resource{
|
||||
{
|
||||
|
@ -237,6 +287,11 @@ func TestAwsApiGatewayRestApiExpander_Execute(t *testing.T) {
|
|||
Type: aws.AwsApiGatewayMethodResponseResourceType,
|
||||
Attrs: &resource.Attributes{},
|
||||
},
|
||||
{
|
||||
Id: "agi-foo-bar-GET",
|
||||
Type: aws.AwsApiGatewayIntegrationResourceType,
|
||||
Attrs: &resource.Attributes{},
|
||||
},
|
||||
},
|
||||
expected: []*resource.Resource{
|
||||
{
|
||||
|
@ -264,6 +319,11 @@ func TestAwsApiGatewayRestApiExpander_Execute(t *testing.T) {
|
|||
Type: aws.AwsApiGatewayMethodResponseResourceType,
|
||||
Attrs: &resource.Attributes{},
|
||||
},
|
||||
{
|
||||
Id: "agi-foo-bar-GET",
|
||||
Type: aws.AwsApiGatewayIntegrationResourceType,
|
||||
Attrs: &resource.Attributes{},
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
|
@ -462,6 +522,46 @@ func TestAwsApiGatewayRestApiExpander_Execute(t *testing.T) {
|
|||
Type: aws.AwsApiGatewayMethodResourceType,
|
||||
Attrs: &resource.Attributes{},
|
||||
})
|
||||
factory.On(
|
||||
"CreateAbstractResource",
|
||||
aws.AwsApiGatewayIntegrationResourceType,
|
||||
"agi-foo-foo-path1-GET",
|
||||
map[string]interface{}{},
|
||||
).Once().Return(&resource.Resource{
|
||||
Id: "agi-foo-foo-path1-GET",
|
||||
Type: aws.AwsApiGatewayIntegrationResourceType,
|
||||
Attrs: &resource.Attributes{},
|
||||
})
|
||||
factory.On(
|
||||
"CreateAbstractResource",
|
||||
aws.AwsApiGatewayIntegrationResourceType,
|
||||
"agi-foo-foo-path1-path2-GET",
|
||||
map[string]interface{}{},
|
||||
).Once().Return(&resource.Resource{
|
||||
Id: "agi-foo-foo-path1-path2-GET",
|
||||
Type: aws.AwsApiGatewayIntegrationResourceType,
|
||||
Attrs: &resource.Attributes{},
|
||||
})
|
||||
factory.On(
|
||||
"CreateAbstractResource",
|
||||
aws.AwsApiGatewayIntegrationResourceType,
|
||||
"agi-bar-bar-path1-GET",
|
||||
map[string]interface{}{},
|
||||
).Once().Return(&resource.Resource{
|
||||
Id: "agi-bar-bar-path1-GET",
|
||||
Type: aws.AwsApiGatewayIntegrationResourceType,
|
||||
Attrs: &resource.Attributes{},
|
||||
})
|
||||
factory.On(
|
||||
"CreateAbstractResource",
|
||||
aws.AwsApiGatewayIntegrationResourceType,
|
||||
"agi-bar-bar-path1-path2-GET",
|
||||
map[string]interface{}{},
|
||||
).Once().Return(&resource.Resource{
|
||||
Id: "agi-bar-bar-path1-path2-GET",
|
||||
Type: aws.AwsApiGatewayIntegrationResourceType,
|
||||
Attrs: &resource.Attributes{},
|
||||
})
|
||||
},
|
||||
resourcesFromState: []*resource.Resource{
|
||||
{
|
||||
|
@ -532,6 +632,26 @@ func TestAwsApiGatewayRestApiExpander_Execute(t *testing.T) {
|
|||
Type: aws.AwsApiGatewayMethodResourceType,
|
||||
Attrs: &resource.Attributes{},
|
||||
},
|
||||
{
|
||||
Id: "agi-foo-foo-path1-GET",
|
||||
Type: aws.AwsApiGatewayIntegrationResourceType,
|
||||
Attrs: &resource.Attributes{},
|
||||
},
|
||||
{
|
||||
Id: "agi-foo-foo-path1-path2-GET",
|
||||
Type: aws.AwsApiGatewayIntegrationResourceType,
|
||||
Attrs: &resource.Attributes{},
|
||||
},
|
||||
{
|
||||
Id: "agi-bar-bar-path1-GET",
|
||||
Type: aws.AwsApiGatewayIntegrationResourceType,
|
||||
Attrs: &resource.Attributes{},
|
||||
},
|
||||
{
|
||||
Id: "agi-bar-bar-path1-path2-GET",
|
||||
Type: aws.AwsApiGatewayIntegrationResourceType,
|
||||
Attrs: &resource.Attributes{},
|
||||
},
|
||||
},
|
||||
expected: []*resource.Resource{
|
||||
{
|
||||
|
@ -600,6 +720,26 @@ func TestAwsApiGatewayRestApiExpander_Execute(t *testing.T) {
|
|||
Type: aws.AwsApiGatewayMethodResourceType,
|
||||
Attrs: &resource.Attributes{},
|
||||
},
|
||||
{
|
||||
Id: "agi-foo-foo-path1-GET",
|
||||
Type: aws.AwsApiGatewayIntegrationResourceType,
|
||||
Attrs: &resource.Attributes{},
|
||||
},
|
||||
{
|
||||
Id: "agi-foo-foo-path1-path2-GET",
|
||||
Type: aws.AwsApiGatewayIntegrationResourceType,
|
||||
Attrs: &resource.Attributes{},
|
||||
},
|
||||
{
|
||||
Id: "agi-bar-bar-path1-GET",
|
||||
Type: aws.AwsApiGatewayIntegrationResourceType,
|
||||
Attrs: &resource.Attributes{},
|
||||
},
|
||||
{
|
||||
Id: "agi-bar-bar-path1-path2-GET",
|
||||
Type: aws.AwsApiGatewayIntegrationResourceType,
|
||||
Attrs: &resource.Attributes{},
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
|
|
|
@ -1510,3 +1510,108 @@ func TestApiGatewayMethodSettings(t *testing.T) {
|
|||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestApiGatewayIntegration(t *testing.T) {
|
||||
dummyError := errors.New("this is an error")
|
||||
apis := []*apigateway.RestApi{
|
||||
{Id: awssdk.String("u7jce3lokk")},
|
||||
}
|
||||
|
||||
tests := []struct {
|
||||
test string
|
||||
mocks func(*repository.MockApiGatewayRepository, *mocks.AlerterInterface)
|
||||
assertExpected func(t *testing.T, got []*resource.Resource)
|
||||
wantErr error
|
||||
}{
|
||||
{
|
||||
test: "no api gateway integrations",
|
||||
mocks: func(repo *repository.MockApiGatewayRepository, alerter *mocks.AlerterInterface) {
|
||||
repo.On("ListAllRestApis").Return(apis, nil)
|
||||
repo.On("ListAllRestApiResources", *apis[0].Id).Return([]*apigateway.Resource{
|
||||
{Id: awssdk.String("z9ag20"), Path: awssdk.String("/foo")},
|
||||
}, nil)
|
||||
},
|
||||
assertExpected: func(t *testing.T, got []*resource.Resource) {
|
||||
assert.Len(t, got, 0)
|
||||
},
|
||||
},
|
||||
{
|
||||
test: "multiple api gateway integrations",
|
||||
mocks: func(repo *repository.MockApiGatewayRepository, alerter *mocks.AlerterInterface) {
|
||||
repo.On("ListAllRestApis").Return(apis, nil)
|
||||
repo.On("ListAllRestApiResources", *apis[0].Id).Return([]*apigateway.Resource{
|
||||
{Id: awssdk.String("z9ag20"), Path: awssdk.String("/foo"), ResourceMethods: map[string]*apigateway.Method{
|
||||
"GET": {},
|
||||
"POST": {},
|
||||
"DELETE": {},
|
||||
}},
|
||||
}, nil)
|
||||
},
|
||||
assertExpected: func(t *testing.T, got []*resource.Resource) {
|
||||
assert.Len(t, got, 3)
|
||||
|
||||
assert.Equal(t, got[0].ResourceId(), "agi-u7jce3lokk-z9ag20-DELETE")
|
||||
assert.Equal(t, got[0].ResourceType(), resourceaws.AwsApiGatewayIntegrationResourceType)
|
||||
|
||||
assert.Equal(t, got[1].ResourceId(), "agi-u7jce3lokk-z9ag20-GET")
|
||||
assert.Equal(t, got[1].ResourceType(), resourceaws.AwsApiGatewayIntegrationResourceType)
|
||||
|
||||
assert.Equal(t, got[2].ResourceId(), "agi-u7jce3lokk-z9ag20-POST")
|
||||
assert.Equal(t, got[2].ResourceType(), resourceaws.AwsApiGatewayIntegrationResourceType)
|
||||
},
|
||||
},
|
||||
{
|
||||
test: "cannot list rest apis",
|
||||
mocks: func(repo *repository.MockApiGatewayRepository, alerter *mocks.AlerterInterface) {
|
||||
repo.On("ListAllRestApis").Return(nil, dummyError)
|
||||
alerter.On("SendAlert", resourceaws.AwsApiGatewayIntegrationResourceType, alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayIntegrationResourceType, resourceaws.AwsApiGatewayRestApiResourceType), alerts.EnumerationPhase)).Return()
|
||||
},
|
||||
wantErr: remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayIntegrationResourceType, resourceaws.AwsApiGatewayRestApiResourceType),
|
||||
},
|
||||
{
|
||||
test: "cannot list api gateway resources",
|
||||
mocks: func(repo *repository.MockApiGatewayRepository, alerter *mocks.AlerterInterface) {
|
||||
repo.On("ListAllRestApis").Return(apis, nil)
|
||||
repo.On("ListAllRestApiResources", *apis[0].Id).Return(nil, dummyError)
|
||||
alerter.On("SendAlert", resourceaws.AwsApiGatewayIntegrationResourceType, alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayIntegrationResourceType, resourceaws.AwsApiGatewayResourceResourceType), alerts.EnumerationPhase)).Return()
|
||||
},
|
||||
wantErr: remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayIntegrationResourceType, resourceaws.AwsApiGatewayResourceResourceType),
|
||||
},
|
||||
}
|
||||
|
||||
providerVersion := "3.19.0"
|
||||
schemaRepository := testresource.InitFakeSchemaRepository("aws", providerVersion)
|
||||
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.MockApiGatewayRepository{}
|
||||
c.mocks(fakeRepo, alerter)
|
||||
|
||||
var repo repository.ApiGatewayRepository = fakeRepo
|
||||
|
||||
remoteLibrary.AddEnumerator(aws.NewApiGatewayIntegrationEnumerator(repo, factory))
|
||||
|
||||
testFilter := &filter.MockFilter{}
|
||||
testFilter.On("IsTypeIgnored", mock.Anything).Return(false)
|
||||
|
||||
s := remote.NewSortableScanner(NewScanner(remoteLibrary, alerter, scanOptions, testFilter))
|
||||
got, err := s.Resources()
|
||||
assert.Equal(tt, err, c.wantErr)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
c.assertExpected(tt, got)
|
||||
alerter.AssertExpectations(tt)
|
||||
fakeRepo.AssertExpectations(tt)
|
||||
testFilter.AssertExpectations(tt)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,59 @@
|
|||
package aws
|
||||
|
||||
import (
|
||||
"strings"
|
||||
|
||||
"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 ApiGatewayIntegrationEnumerator struct {
|
||||
repository repository.ApiGatewayRepository
|
||||
factory resource.ResourceFactory
|
||||
}
|
||||
|
||||
func NewApiGatewayIntegrationEnumerator(repo repository.ApiGatewayRepository, factory resource.ResourceFactory) *ApiGatewayIntegrationEnumerator {
|
||||
return &ApiGatewayIntegrationEnumerator{
|
||||
repository: repo,
|
||||
factory: factory,
|
||||
}
|
||||
}
|
||||
|
||||
func (e *ApiGatewayIntegrationEnumerator) SupportedType() resource.ResourceType {
|
||||
return aws.AwsApiGatewayIntegrationResourceType
|
||||
}
|
||||
|
||||
func (e *ApiGatewayIntegrationEnumerator) Enumerate() ([]*resource.Resource, error) {
|
||||
apis, err := e.repository.ListAllRestApis()
|
||||
if err != nil {
|
||||
return nil, remoteerror.NewResourceListingErrorWithType(err, string(e.SupportedType()), aws.AwsApiGatewayRestApiResourceType)
|
||||
}
|
||||
|
||||
results := make([]*resource.Resource, 0)
|
||||
|
||||
for _, api := range apis {
|
||||
a := api
|
||||
resources, err := e.repository.ListAllRestApiResources(*a.Id)
|
||||
if err != nil {
|
||||
return nil, remoteerror.NewResourceListingErrorWithType(err, string(e.SupportedType()), aws.AwsApiGatewayResourceResourceType)
|
||||
}
|
||||
|
||||
for _, resource := range resources {
|
||||
r := resource
|
||||
for httpMethod := range r.ResourceMethods {
|
||||
results = append(
|
||||
results,
|
||||
e.factory.CreateAbstractResource(
|
||||
string(e.SupportedType()),
|
||||
strings.Join([]string{"agi", *a.Id, *r.Id, httpMethod}, "-"),
|
||||
map[string]interface{}{},
|
||||
),
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return results, err
|
||||
}
|
|
@ -198,6 +198,7 @@ func Init(version string, alerter *alerter.Alerter,
|
|||
remoteLibrary.AddEnumerator(NewApiGatewayMethodResponseEnumerator(apigatewayRepository, factory))
|
||||
remoteLibrary.AddEnumerator(NewApiGatewayGatewayResponseEnumerator(apigatewayRepository, factory))
|
||||
remoteLibrary.AddEnumerator(NewApiGatewayMethodSettingsEnumerator(apigatewayRepository, factory))
|
||||
remoteLibrary.AddEnumerator(NewApiGatewayIntegrationEnumerator(apigatewayRepository, factory))
|
||||
|
||||
remoteLibrary.AddEnumerator(NewAppAutoscalingTargetEnumerator(appAutoScalingRepository, factory))
|
||||
remoteLibrary.AddDetailsFetcher(aws.AwsAppAutoscalingTargetResourceType, common.NewGenericDetailsFetcher(aws.AwsAppAutoscalingTargetResourceType, provider, deserializer))
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
package aws
|
||||
|
||||
const AwsApiGatewayIntegrationResourceType = "aws_api_gateway_integration"
|
|
@ -0,0 +1,30 @@
|
|||
package aws_test
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/cloudskiff/driftctl/test"
|
||||
"github.com/cloudskiff/driftctl/test/acceptance"
|
||||
)
|
||||
|
||||
func TestAcc_Aws_ApiGatewayIntegration(t *testing.T) {
|
||||
acceptance.Run(t, acceptance.AccTestCase{
|
||||
TerraformVersion: "0.15.5",
|
||||
Paths: []string{"./testdata/acc/aws_api_gateway_integration"},
|
||||
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(3)
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
}
|
|
@ -19,6 +19,7 @@ func TestAWS_Metadata_Flags(t *testing.T) {
|
|||
AwsApiGatewayDeploymentResourceType: {},
|
||||
AwsApiGatewayDomainNameResourceType: {},
|
||||
AwsApiGatewayGatewayResponseResourceType: {},
|
||||
AwsApiGatewayIntegrationResourceType: {},
|
||||
AwsApiGatewayMethodResourceType: {},
|
||||
AwsApiGatewayMethodResponseResourceType: {},
|
||||
AwsApiGatewayMethodSettingsResourceType: {},
|
||||
|
|
|
@ -0,0 +1,2 @@
|
|||
*
|
||||
!aws_api_gateway_integration
|
20
pkg/resource/aws/testdata/acc/aws_api_gateway_integration/.terraform.lock.hcl
vendored
Normal file
20
pkg/resource/aws/testdata/acc/aws_api_gateway_integration/.terraform.lock.hcl
vendored
Normal file
|
@ -0,0 +1,20 @@
|
|||
# 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:xur9tF49NgsovNnmwmBR8RdpN8Fcg1TD4CKQPJD6n1A=",
|
||||
"zh:185a5259153eb9ee4699d4be43b3d509386b473683392034319beee97d470c3b",
|
||||
"zh:2d9a0a01f93e8d16539d835c02b8b6e1927b7685f4076e96cb07f7dd6944bc6c",
|
||||
"zh:703f6da36b1b5f3497baa38fccaa7765fb8a2b6440344e4c97172516b49437dd",
|
||||
"zh:770855565462abadbbddd98cb357d2f1a8f30f68a358cb37cbd5c072cb15b377",
|
||||
"zh:8008db43149fe4345301f81e15e6d9ddb47aa5e7a31648f9b290af96ad86e92a",
|
||||
"zh:8cdd27d375da6dcb7687f1fed126b7c04efce1671066802ee876dbbc9c66ec79",
|
||||
"zh:be22ae185005690d1a017c1b909e0d80ab567e239b4f06ecacdba85080667c1c",
|
||||
"zh:d2d02e72dbd80f607636cd6237a6c862897caabc635c7b50c0cb243d11246723",
|
||||
"zh:d8f125b66a1eda2555c0f9bbdf12036a5f8d073499a22ca9e4812b68067fea31",
|
||||
"zh:f5a98024c64d5d2973ff15b093725a074c0cb4afde07ef32c542e69f17ac90bc",
|
||||
]
|
||||
}
|
|
@ -0,0 +1,92 @@
|
|||
provider "aws" {
|
||||
region = "us-east-1"
|
||||
}
|
||||
|
||||
terraform {
|
||||
required_providers {
|
||||
aws = "3.19.0"
|
||||
}
|
||||
}
|
||||
|
||||
resource "aws_api_gateway_rest_api" "foo" {
|
||||
name = "foo"
|
||||
description = "This is foo API"
|
||||
}
|
||||
|
||||
resource "aws_api_gateway_resource" "foo" {
|
||||
rest_api_id = aws_api_gateway_rest_api.foo.id
|
||||
parent_id = aws_api_gateway_rest_api.foo.root_resource_id
|
||||
path_part = "foo"
|
||||
}
|
||||
|
||||
resource "aws_api_gateway_method" "foo" {
|
||||
rest_api_id = aws_api_gateway_rest_api.foo.id
|
||||
resource_id = aws_api_gateway_resource.foo.id
|
||||
http_method = "GET"
|
||||
authorization = "NONE"
|
||||
}
|
||||
|
||||
resource "aws_api_gateway_integration" "foo" {
|
||||
http_method = aws_api_gateway_method.foo.http_method
|
||||
resource_id = aws_api_gateway_resource.foo.id
|
||||
rest_api_id = aws_api_gateway_rest_api.foo.id
|
||||
type = "MOCK"
|
||||
}
|
||||
|
||||
resource "aws_api_gateway_rest_api" "bar" {
|
||||
name = "bar"
|
||||
description = "This is bar API"
|
||||
body = jsonencode({
|
||||
openapi = "3.0.1"
|
||||
info = {
|
||||
title = "example"
|
||||
version = "1.0"
|
||||
}
|
||||
paths = {
|
||||
"/path1" = {
|
||||
get = {
|
||||
x-amazon-apigateway-integration = {
|
||||
httpMethod = "GET"
|
||||
payloadFormatVersion = "1.0"
|
||||
type = "HTTP_PROXY"
|
||||
uri = "https://ip-ranges.amazonaws.com/ip-ranges.json"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
resource "aws_api_gateway_rest_api" "baz" {
|
||||
name = "baz"
|
||||
description = "This is baz API"
|
||||
body = jsonencode({
|
||||
swagger = "2.0"
|
||||
info = {
|
||||
title = "test"
|
||||
version = "2017-04-20T04:08:08Z"
|
||||
}
|
||||
schemes = ["https"]
|
||||
paths = {
|
||||
"/test" = {
|
||||
get = {
|
||||
responses = {
|
||||
"200" = {
|
||||
description = "OK"
|
||||
}
|
||||
}
|
||||
x-amazon-apigateway-integration = {
|
||||
httpMethod = "GET"
|
||||
type = "HTTP"
|
||||
responses = {
|
||||
default = {
|
||||
statusCode = 200
|
||||
}
|
||||
}
|
||||
uri = "https://aws.amazon.com/"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
|
@ -115,6 +115,7 @@ var supportedTypes = map[string]ResourceTypeMeta{
|
|||
"aws_api_gateway_stage": {},
|
||||
"aws_api_gateway_resource": {children: []ResourceType{
|
||||
"aws_api_gateway_method",
|
||||
"aws_api_gateway_integration",
|
||||
}},
|
||||
"aws_api_gateway_domain_name": {},
|
||||
"aws_api_gateway_vpc_link": {},
|
||||
|
@ -128,6 +129,7 @@ var supportedTypes = map[string]ResourceTypeMeta{
|
|||
"aws_api_gateway_method_response": {},
|
||||
"aws_api_gateway_gateway_response": {},
|
||||
"aws_api_gateway_method_settings": {},
|
||||
"aws_api_gateway_integration": {},
|
||||
"aws_appautoscaling_target": {},
|
||||
"aws_rds_cluster_instance": {children: []ResourceType{
|
||||
"aws_db_instance",
|
||||
|
|
Loading…
Reference in New Issue