Add aws_sqs_queue
parent
9ea6b68873
commit
ad5ad4cc76
|
@ -126,7 +126,10 @@ As AWS documentation recommends, the below policy is granting only the permissio
|
|||
"s3:GetMetricsConfiguration",
|
||||
"s3:GetReplicationConfiguration",
|
||||
"s3:ListAllMyBuckets",
|
||||
"s3:ListBucket"
|
||||
"s3:ListBucket",
|
||||
"sqs:GetQueueAttributes",
|
||||
"sqs:ListQueueTags",
|
||||
"sqs:ListQueues"
|
||||
]
|
||||
}
|
||||
]
|
||||
|
@ -237,3 +240,8 @@ As AWS documentation recommends, the below policy is granting only the permissio
|
|||
- [x] aws_route_table_association
|
||||
- [x] aws_nat_gateway
|
||||
- [x] aws_internet_gateway
|
||||
|
||||
## SQS
|
||||
|
||||
- [x] aws_sqs_queue
|
||||
- [ ] aws_sqs_queue_policy
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -47,5 +47,6 @@ func Deserializers() []deserializer.CTYDeserializer {
|
|||
awsdeserializer.NewRouteTableAssociationDeserializer(),
|
||||
awsdeserializer.NewNatGatewayDeserializer(),
|
||||
awsdeserializer.NewInternetGatewayDeserializer(),
|
||||
awsdeserializer.NewSqsQueueDeserializer(),
|
||||
}
|
||||
}
|
||||
|
|
|
@ -74,6 +74,7 @@ func TestTerraformStateReader_Resources(t *testing.T) {
|
|||
{name: "route table associations", dirName: "route_assoc", wantErr: false},
|
||||
{name: "NAT gateway", dirName: "aws_nat_gateway", wantErr: false},
|
||||
{name: "Internet Gateway", dirName: "internet_gateway", wantErr: false},
|
||||
{name: "SQS queue", dirName: "sqs_queue", wantErr: false},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
|
|
|
@ -0,0 +1,38 @@
|
|||
[
|
||||
{
|
||||
"Arn": "arn:aws:sqs:eu-west-3:047081014315:bar.fifo",
|
||||
"ContentBasedDeduplication": true,
|
||||
"DelaySeconds": 0,
|
||||
"FifoQueue": true,
|
||||
"Id": "https://sqs.eu-west-3.amazonaws.com/047081014315/bar.fifo",
|
||||
"KmsDataKeyReusePeriodSeconds": 300,
|
||||
"KmsMasterKeyId": "",
|
||||
"MaxMessageSize": 262144,
|
||||
"MessageRetentionSeconds": 345600,
|
||||
"Name": "bar.fifo",
|
||||
"NamePrefix": null,
|
||||
"Policy": "",
|
||||
"ReceiveWaitTimeSeconds": 0,
|
||||
"RedrivePolicy": "",
|
||||
"Tags": {},
|
||||
"VisibilityTimeoutSeconds": 30
|
||||
},
|
||||
{
|
||||
"Arn": "arn:aws:sqs:eu-west-3:047081014315:foo",
|
||||
"ContentBasedDeduplication": false,
|
||||
"DelaySeconds": 0,
|
||||
"FifoQueue": false,
|
||||
"Id": "https://sqs.eu-west-3.amazonaws.com/047081014315/foo",
|
||||
"KmsDataKeyReusePeriodSeconds": 300,
|
||||
"KmsMasterKeyId": "",
|
||||
"MaxMessageSize": 262144,
|
||||
"MessageRetentionSeconds": 345600,
|
||||
"Name": "foo",
|
||||
"NamePrefix": null,
|
||||
"Policy": "",
|
||||
"ReceiveWaitTimeSeconds": 0,
|
||||
"RedrivePolicy": "",
|
||||
"Tags": {},
|
||||
"VisibilityTimeoutSeconds": 30
|
||||
}
|
||||
]
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,71 @@
|
|||
{
|
||||
"version": 4,
|
||||
"terraform_version": "0.14.5",
|
||||
"serial": 596,
|
||||
"lineage": "cc4be827-a907-1623-961b-0fc1ce33973e",
|
||||
"outputs": {},
|
||||
"resources": [
|
||||
{
|
||||
"mode": "managed",
|
||||
"type": "aws_sqs_queue",
|
||||
"name": "bar",
|
||||
"provider": "provider[\"registry.terraform.io/hashicorp/aws\"]",
|
||||
"instances": [
|
||||
{
|
||||
"schema_version": 0,
|
||||
"attributes": {
|
||||
"arn": "arn:aws:sqs:eu-west-3:047081014315:bar.fifo",
|
||||
"content_based_deduplication": true,
|
||||
"delay_seconds": 0,
|
||||
"fifo_queue": true,
|
||||
"id": "https://sqs.eu-west-3.amazonaws.com/047081014315/bar.fifo",
|
||||
"kms_data_key_reuse_period_seconds": 300,
|
||||
"kms_master_key_id": "",
|
||||
"max_message_size": 262144,
|
||||
"message_retention_seconds": 345600,
|
||||
"name": "bar.fifo",
|
||||
"name_prefix": null,
|
||||
"policy": "",
|
||||
"receive_wait_time_seconds": 0,
|
||||
"redrive_policy": "",
|
||||
"tags": {},
|
||||
"visibility_timeout_seconds": 30
|
||||
},
|
||||
"sensitive_attributes": [],
|
||||
"private": "bnVsbA=="
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"mode": "managed",
|
||||
"type": "aws_sqs_queue",
|
||||
"name": "foo",
|
||||
"provider": "provider[\"registry.terraform.io/hashicorp/aws\"]",
|
||||
"instances": [
|
||||
{
|
||||
"schema_version": 0,
|
||||
"attributes": {
|
||||
"arn": "arn:aws:sqs:eu-west-3:047081014315:foo",
|
||||
"content_based_deduplication": false,
|
||||
"delay_seconds": 0,
|
||||
"fifo_queue": false,
|
||||
"id": "https://sqs.eu-west-3.amazonaws.com/047081014315/foo",
|
||||
"kms_data_key_reuse_period_seconds": 300,
|
||||
"kms_master_key_id": "",
|
||||
"max_message_size": 262144,
|
||||
"message_retention_seconds": 345600,
|
||||
"name": "foo",
|
||||
"name_prefix": null,
|
||||
"policy": "",
|
||||
"receive_wait_time_seconds": 0,
|
||||
"redrive_policy": "",
|
||||
"tags": {},
|
||||
"visibility_timeout_seconds": 30
|
||||
},
|
||||
"sensitive_attributes": [],
|
||||
"private": "bnVsbA=="
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
|
@ -1,6 +1,7 @@
|
|||
package aws
|
||||
|
||||
import (
|
||||
"github.com/aws/aws-sdk-go/service/sqs"
|
||||
"github.com/cloudskiff/driftctl/pkg/alerter"
|
||||
"github.com/cloudskiff/driftctl/pkg/resource"
|
||||
"github.com/cloudskiff/driftctl/pkg/terraform"
|
||||
|
@ -57,6 +58,8 @@ func Init(alerter *alerter.Alerter, providerLibrary *terraform.ProviderLibrary,
|
|||
supplierLibrary.AddSupplier(NewRouteTableAssociationSupplier(provider))
|
||||
supplierLibrary.AddSupplier(NewNatGatewaySupplier(provider))
|
||||
supplierLibrary.AddSupplier(NewInternetGatewaySupplier(provider))
|
||||
supplierLibrary.AddSupplier(NewSqsQueueSupplier(provider))
|
||||
resource.AddSupplier(NewSqsQueuePolicySupplier(provider.Runner().SubRunner(), sqs.New(provider.session)))
|
||||
|
||||
return nil
|
||||
}
|
||||
|
|
|
@ -0,0 +1,81 @@
|
|||
package aws
|
||||
|
||||
import (
|
||||
"github.com/aws/aws-sdk-go/service/sqs"
|
||||
"github.com/aws/aws-sdk-go/service/sqs/sqsiface"
|
||||
"github.com/cloudskiff/driftctl/pkg/remote/deserializer"
|
||||
remoteerror "github.com/cloudskiff/driftctl/pkg/remote/error"
|
||||
"github.com/cloudskiff/driftctl/pkg/resource"
|
||||
"github.com/cloudskiff/driftctl/pkg/resource/aws"
|
||||
awsdeserializer "github.com/cloudskiff/driftctl/pkg/resource/aws/deserializer"
|
||||
"github.com/cloudskiff/driftctl/pkg/terraform"
|
||||
"github.com/sirupsen/logrus"
|
||||
"github.com/zclconf/go-cty/cty"
|
||||
)
|
||||
|
||||
type SqsQueueSupplier struct {
|
||||
reader terraform.ResourceReader
|
||||
deserializer deserializer.CTYDeserializer
|
||||
client sqsiface.SQSAPI
|
||||
runner *terraform.ParallelResourceReader
|
||||
}
|
||||
|
||||
func NewSqsQueueSupplier(provider *TerraformProvider) *SqsQueueSupplier {
|
||||
return &SqsQueueSupplier{
|
||||
provider,
|
||||
awsdeserializer.NewSqsQueueDeserializer(),
|
||||
sqs.New(provider.session),
|
||||
terraform.NewParallelResourceReader(provider.Runner().SubRunner()),
|
||||
}
|
||||
}
|
||||
|
||||
func (s SqsQueueSupplier) Resources() ([]resource.Resource, error) {
|
||||
queues, err := listSqsQueues(s.client)
|
||||
if err != nil {
|
||||
return nil, remoteerror.NewResourceEnumerationError(err, aws.AwsSqsQueueResourceType)
|
||||
}
|
||||
|
||||
for _, queue := range queues {
|
||||
q := *queue
|
||||
s.runner.Run(func() (cty.Value, error) {
|
||||
return s.readSqsQueue(q)
|
||||
})
|
||||
}
|
||||
|
||||
resources, err := s.runner.Wait()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return s.deserializer.Deserialize(resources)
|
||||
}
|
||||
|
||||
func (s SqsQueueSupplier) readSqsQueue(queue string) (cty.Value, error) {
|
||||
var Ty resource.ResourceType = aws.AwsSqsQueueResourceType
|
||||
val, err := s.reader.ReadResource(terraform.ReadResourceArgs{
|
||||
Ty: Ty,
|
||||
ID: queue,
|
||||
})
|
||||
if err != nil {
|
||||
logrus.WithFields(logrus.Fields{
|
||||
"type": Ty,
|
||||
}).Error(err)
|
||||
return cty.NilVal, err
|
||||
}
|
||||
return *val, nil
|
||||
}
|
||||
|
||||
func listSqsQueues(client sqsiface.SQSAPI) ([]*string, error) {
|
||||
var queues []*string
|
||||
input := sqs.ListQueuesInput{}
|
||||
err := client.ListQueuesPages(&input,
|
||||
func(resp *sqs.ListQueuesOutput, lastPage bool) bool {
|
||||
queues = append(queues, resp.QueueUrls...)
|
||||
return !lastPage
|
||||
},
|
||||
)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return queues, nil
|
||||
}
|
|
@ -0,0 +1,113 @@
|
|||
package aws
|
||||
|
||||
import (
|
||||
"context"
|
||||
"testing"
|
||||
|
||||
"github.com/aws/aws-sdk-go/aws/awserr"
|
||||
remoteerror "github.com/cloudskiff/driftctl/pkg/remote/error"
|
||||
resourceaws "github.com/cloudskiff/driftctl/pkg/resource/aws"
|
||||
|
||||
"github.com/aws/aws-sdk-go/service/sqs"
|
||||
|
||||
awssdk "github.com/aws/aws-sdk-go/aws"
|
||||
|
||||
"github.com/cloudskiff/driftctl/mocks"
|
||||
"github.com/cloudskiff/driftctl/pkg/parallel"
|
||||
"github.com/cloudskiff/driftctl/pkg/remote/deserializer"
|
||||
"github.com/cloudskiff/driftctl/pkg/resource"
|
||||
awsdeserializer "github.com/cloudskiff/driftctl/pkg/resource/aws/deserializer"
|
||||
"github.com/cloudskiff/driftctl/pkg/terraform"
|
||||
"github.com/cloudskiff/driftctl/test"
|
||||
"github.com/cloudskiff/driftctl/test/goldenfile"
|
||||
mocks2 "github.com/cloudskiff/driftctl/test/mocks"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/mock"
|
||||
)
|
||||
|
||||
func TestSqsQueueSupplier_Resources(t *testing.T) {
|
||||
cases := []struct {
|
||||
test string
|
||||
dirName string
|
||||
mocks func(client *mocks.FakeSQS)
|
||||
err error
|
||||
}{
|
||||
{
|
||||
test: "no sqs queues",
|
||||
dirName: "sqs_queue_empty",
|
||||
mocks: func(client *mocks.FakeSQS) {
|
||||
client.On("ListQueuesPages",
|
||||
&sqs.ListQueuesInput{},
|
||||
mock.MatchedBy(func(callback func(res *sqs.ListQueuesOutput, lastPage bool) bool) bool {
|
||||
callback(&sqs.ListQueuesOutput{}, true)
|
||||
return true
|
||||
})).Return(nil)
|
||||
},
|
||||
err: nil,
|
||||
},
|
||||
{
|
||||
test: "multiple sqs queues",
|
||||
dirName: "sqs_queue_multiple",
|
||||
mocks: func(client *mocks.FakeSQS) {
|
||||
client.On("ListQueuesPages",
|
||||
&sqs.ListQueuesInput{},
|
||||
mock.MatchedBy(func(callback func(res *sqs.ListQueuesOutput, lastPage bool) bool) bool {
|
||||
callback(&sqs.ListQueuesOutput{
|
||||
QueueUrls: []*string{
|
||||
awssdk.String("https://sqs.eu-west-3.amazonaws.com/047081014315/bar.fifo"),
|
||||
awssdk.String("https://sqs.eu-west-3.amazonaws.com/047081014315/foo"),
|
||||
},
|
||||
}, true)
|
||||
return true
|
||||
})).Return(nil)
|
||||
},
|
||||
err: nil,
|
||||
},
|
||||
{
|
||||
test: "cannot list sqs queues",
|
||||
dirName: "sqs_queue_empty",
|
||||
mocks: func(client *mocks.FakeSQS) {
|
||||
client.On(
|
||||
"ListQueuesPages",
|
||||
&sqs.ListQueuesInput{},
|
||||
mock.Anything,
|
||||
).Once().Return(awserr.NewRequestFailure(nil, 403, ""))
|
||||
},
|
||||
err: remoteerror.NewResourceEnumerationError(awserr.NewRequestFailure(nil, 403, ""), resourceaws.AwsSqsQueueResourceType),
|
||||
},
|
||||
}
|
||||
for _, c := range cases {
|
||||
shouldUpdate := c.dirName == *goldenfile.Update
|
||||
providerLibrary := terraform.NewProviderLibrary()
|
||||
supplierLibrary := resource.NewSupplierLibrary()
|
||||
|
||||
if shouldUpdate {
|
||||
provider, err := NewTerraFormProvider()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
providerLibrary.AddProvider(terraform.AWS, provider)
|
||||
supplierLibrary.AddSupplier(NewSqsQueueSupplier(provider))
|
||||
}
|
||||
|
||||
t.Run(c.test, func(tt *testing.T) {
|
||||
fakeSQS := mocks.FakeSQS{}
|
||||
c.mocks(&fakeSQS)
|
||||
provider := mocks2.NewMockedGoldenTFProvider(c.dirName, providerLibrary.Provider(terraform.AWS), shouldUpdate)
|
||||
sqsQueueDeserializer := awsdeserializer.NewSqsQueueDeserializer()
|
||||
s := &SqsQueueSupplier{
|
||||
provider,
|
||||
sqsQueueDeserializer,
|
||||
&fakeSQS,
|
||||
terraform.NewParallelResourceReader(parallel.NewParallelRunner(context.TODO(), 10)),
|
||||
}
|
||||
got, err := s.Resources()
|
||||
assert.Equal(tt, c.err, err)
|
||||
|
||||
mock.AssertExpectationsForObjects(tt)
|
||||
deserializers := []deserializer.CTYDeserializer{sqsQueueDeserializer}
|
||||
test.CtyTestDiffMixed(got, c.dirName, provider, deserializers, shouldUpdate, tt)
|
||||
})
|
||||
}
|
||||
}
|
|
@ -0,0 +1 @@
|
|||
[]
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,5 @@
|
|||
{
|
||||
"Typ": "WyJvYmplY3QiLHsiYXJuIjoic3RyaW5nIiwiY29udGVudF9iYXNlZF9kZWR1cGxp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NDQsIm1lc3NhZ2VfcmV0ZW50aW9uX3NlY29uZHMiOjM0NTYwMCwibmFtZSI6ImZvbyIsIm5hbWVfcHJlZml4IjpudWxsLCJwb2xpY3kiOiIiLCJyZWNlaXZlX3dhaXRfdGltZV9zZWNvbmRzIjowLCJyZWRyaXZlX3BvbGljeSI6IiIsInRhZ3MiOnt9LCJ2aXNpYmlsaXR5X3RpbWVvdXRfc2Vjb25kcyI6MzB9",
|
||||
"Err": null
|
||||
}
|
|
@ -0,0 +1,38 @@
|
|||
[
|
||||
{
|
||||
"arn": "arn:aws:sqs:eu-west-3:047081014315:foo",
|
||||
"content_based_deduplication": false,
|
||||
"delay_seconds": 0,
|
||||
"fifo_queue": false,
|
||||
"id": "https://sqs.eu-west-3.amazonaws.com/047081014315/foo",
|
||||
"kms_data_key_reuse_period_seconds": 300,
|
||||
"kms_master_key_id": "",
|
||||
"max_message_size": 262144,
|
||||
"message_retention_seconds": 345600,
|
||||
"name": "foo",
|
||||
"name_prefix": null,
|
||||
"policy": "",
|
||||
"receive_wait_time_seconds": 0,
|
||||
"redrive_policy": "",
|
||||
"tags": {},
|
||||
"visibility_timeout_seconds": 30
|
||||
},
|
||||
{
|
||||
"arn": "arn:aws:sqs:eu-west-3:047081014315:bar.fifo",
|
||||
"content_based_deduplication": true,
|
||||
"delay_seconds": 0,
|
||||
"fifo_queue": true,
|
||||
"id": "https://sqs.eu-west-3.amazonaws.com/047081014315/bar.fifo",
|
||||
"kms_data_key_reuse_period_seconds": 300,
|
||||
"kms_master_key_id": "",
|
||||
"max_message_size": 262144,
|
||||
"message_retention_seconds": 345600,
|
||||
"name": "bar.fifo",
|
||||
"name_prefix": null,
|
||||
"policy": "",
|
||||
"receive_wait_time_seconds": 0,
|
||||
"redrive_policy": "",
|
||||
"tags": {},
|
||||
"visibility_timeout_seconds": 30
|
||||
}
|
||||
]
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,19 @@
|
|||
provider "aws" {
|
||||
region = "us-east-1"
|
||||
}
|
||||
|
||||
terraform {
|
||||
required_providers {
|
||||
aws = "3.19.0"
|
||||
}
|
||||
}
|
||||
|
||||
resource "aws_sqs_queue" "foo" {
|
||||
name = "foo"
|
||||
}
|
||||
|
||||
resource "aws_sqs_queue" "bar" {
|
||||
name = "bar.fifo"
|
||||
fifo_queue = true
|
||||
content_based_deduplication = true
|
||||
}
|
|
@ -0,0 +1,31 @@
|
|||
// GENERATED, DO NOT EDIT THIS FILE
|
||||
package aws
|
||||
|
||||
const AwsSqsQueueResourceType = "aws_sqs_queue"
|
||||
|
||||
type AwsSqsQueue struct {
|
||||
Arn *string `cty:"arn" computed:"true"`
|
||||
ContentBasedDeduplication *bool `cty:"content_based_deduplication"`
|
||||
DelaySeconds *int `cty:"delay_seconds"`
|
||||
FifoQueue *bool `cty:"fifo_queue"`
|
||||
Id string `cty:"id" computed:"true"`
|
||||
KmsDataKeyReusePeriodSeconds *int `cty:"kms_data_key_reuse_period_seconds" computed:"true"`
|
||||
KmsMasterKeyId *string `cty:"kms_master_key_id"`
|
||||
MaxMessageSize *int `cty:"max_message_size"`
|
||||
MessageRetentionSeconds *int `cty:"message_retention_seconds"`
|
||||
Name *string `cty:"name" computed:"true"`
|
||||
NamePrefix *string `cty:"name_prefix"`
|
||||
Policy *string `cty:"policy" computed:"true"`
|
||||
ReceiveWaitTimeSeconds *int `cty:"receive_wait_time_seconds"`
|
||||
RedrivePolicy *string `cty:"redrive_policy"`
|
||||
Tags map[string]string `cty:"tags"`
|
||||
VisibilityTimeoutSeconds *int `cty:"visibility_timeout_seconds"`
|
||||
}
|
||||
|
||||
func (r *AwsSqsQueue) TerraformId() string {
|
||||
return r.Id
|
||||
}
|
||||
|
||||
func (r *AwsSqsQueue) TerraformType() string {
|
||||
return AwsSqsQueueResourceType
|
||||
}
|
|
@ -0,0 +1,28 @@
|
|||
package aws_test
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/cloudskiff/driftctl/test/acceptance"
|
||||
)
|
||||
|
||||
func TestAcc_AwsSqsQueue(t *testing.T) {
|
||||
acceptance.Run(t, acceptance.AccTestCase{
|
||||
Path: "./testdata/acc/aws_sqs_queue",
|
||||
Args: []string{"scan", "--filter", "Type=='aws_sqs_queue'"},
|
||||
Checks: []acceptance.AccCheck{
|
||||
{
|
||||
Env: map[string]string{
|
||||
"AWS_REGION": "us-east-1",
|
||||
},
|
||||
Check: func(result *acceptance.ScanResult, stdout string, err error) {
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
result.AssertInfrastructureIsInSync()
|
||||
result.Equal(2, result.Summary().TotalManaged)
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
}
|
|
@ -0,0 +1,43 @@
|
|||
package deserializer
|
||||
|
||||
import (
|
||||
"github.com/cloudskiff/driftctl/pkg/resource"
|
||||
resourceaws "github.com/cloudskiff/driftctl/pkg/resource/aws"
|
||||
"github.com/sirupsen/logrus"
|
||||
"github.com/zclconf/go-cty/cty"
|
||||
"github.com/zclconf/go-cty/cty/gocty"
|
||||
)
|
||||
|
||||
type SqsQueueDeserializer struct {
|
||||
}
|
||||
|
||||
func NewSqsQueueDeserializer() *SqsQueueDeserializer {
|
||||
return &SqsQueueDeserializer{}
|
||||
}
|
||||
|
||||
func (s *SqsQueueDeserializer) HandledType() resource.ResourceType {
|
||||
return resourceaws.AwsSqsQueueResourceType
|
||||
}
|
||||
|
||||
func (s SqsQueueDeserializer) Deserialize(rawList []cty.Value) ([]resource.Resource, error) {
|
||||
resources := make([]resource.Resource, 0)
|
||||
for _, rawResource := range rawList {
|
||||
resource, err := decodeSqsQueue(&rawResource)
|
||||
if err != nil {
|
||||
logrus.WithFields(logrus.Fields{
|
||||
"type": s.HandledType(),
|
||||
}).Warnf("Error when deserializing resource %+v : %+v", rawResource, err)
|
||||
return nil, err
|
||||
}
|
||||
resources = append(resources, resource)
|
||||
}
|
||||
return resources, nil
|
||||
}
|
||||
|
||||
func decodeSqsQueue(raw *cty.Value) (*resourceaws.AwsSqsQueue, error) {
|
||||
var decoded resourceaws.AwsSqsQueue
|
||||
if err := gocty.FromCtyValue(*raw, &decoded); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &decoded, nil
|
||||
}
|
|
@ -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,19 @@
|
|||
provider "aws" {
|
||||
region = "us-east-1"
|
||||
}
|
||||
|
||||
terraform {
|
||||
required_providers {
|
||||
aws = "3.19.0"
|
||||
}
|
||||
}
|
||||
|
||||
resource "aws_sqs_queue" "foo" {
|
||||
name = "foo"
|
||||
}
|
||||
|
||||
resource "aws_sqs_queue" "bar" {
|
||||
name = "bar.fifo"
|
||||
fifo_queue = true
|
||||
content_based_deduplication = true
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
package aws
|
||||
|
||||
import (
|
||||
"github.com/aws/aws-sdk-go/service/sqs/sqsiface"
|
||||
)
|
||||
|
||||
type FakeSQS interface {
|
||||
sqsiface.SQSAPI
|
||||
}
|
Loading…
Reference in New Issue