Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

r/aws_sqs_queue_policy: Support import by queue URL #2544

Merged
merged 1 commit into from
Dec 11, 2017

Conversation

bflad
Copy link
Contributor

@bflad bflad commented Dec 5, 2017

Via migrating the ID to remove the sqs-policy- prefix. Includes some other minor cleanup.

Closes #1501

make testacc TEST=./aws TESTARGS='-run=\(TestAWSSqsQueuePolicyMigrateState\|TestAccAWSSQSQueuePolicy\)'
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./aws -v -run=\(TestAWSSqsQueuePolicyMigrateState\|TestAccAWSSQSQueuePolicy\) -timeout 120m
=== RUN   TestAWSSqsQueuePolicyMigrateState
2017/12/05 01:50:46 [INFO] Found AWS SQS Query Policy State v0; migrating to v1
2017/12/05 01:50:46 [DEBUG] Attributes before migration: map[string]string{"policy":"{}", "queue_url":"https://queue.amazonaws.com/0123456789012/myqueue"}
2017/12/05 01:50:46 [DEBUG] Attributes after migration: map[string]string{"queue_url":"https://queue.amazonaws.com/0123456789012/myqueue", "id":"https://queue.amazonaws.com/0123456789012/myqueue", "policy":"{}"}, new id: https://queue.amazonaws.com/0123456789012/myqueue
--- PASS: TestAWSSqsQueuePolicyMigrateState (0.00s)
=== RUN   TestAccAWSSQSQueuePolicy_basic
--- PASS: TestAccAWSSQSQueuePolicy_basic (15.93s)
=== RUN   TestAccAWSSQSQueuePolicy_import
--- PASS: TestAccAWSSQSQueuePolicy_import (16.23s)
PASS
ok  	github.com/terraform-providers/terraform-provider-aws/aws	32.198s

@Ninir Ninir added the enhancement Requests to existing resources that expand the functionality or scope. label Dec 5, 2017
@radeksimko radeksimko added the upstream-terraform Addresses functionality related to the Terraform core binary. label Dec 5, 2017
Copy link
Contributor

@Ninir Ninir left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @bflad

This is looking very good to me :)
Just asking Radek about the will behind the initial ID string, otherwise this is looking very good!

$ make testacc TEST=./aws TESTARGS='-run=\(TestAWSSqsQueuePolicyMigrateState\|TestAccAWSSQSQueuePolicy\)'

==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./aws -v -run=\(TestAWSSqsQueuePolicyMigrateState\|TestAccAWSSQSQueuePolicy\) -timeout 120m
=== RUN   TestAWSSqsQueuePolicyMigrateState
2017/12/08 15:48:44 [INFO] Found AWS SQS Query Policy State v0; migrating to v1
2017/12/08 15:48:44 [DEBUG] Attributes before migration: map[string]string{"policy":"{}", "queue_url":"https://queue.amazonaws.com/0123456789012/myqueue"}
2017/12/08 15:48:44 [DEBUG] Attributes after migration: map[string]string{"queue_url":"https://queue.amazonaws.com/0123456789012/myqueue", "id":"https://queue.amazonaws.com/0123456789012/myqueue", "policy":"{}"}, new id: https://queue.amazonaws.com/0123456789012/myqueue
--- PASS: TestAWSSqsQueuePolicyMigrateState (0.00s)
=== RUN   TestAccAWSSQSQueuePolicy_basic
--- PASS: TestAccAWSSQSQueuePolicy_basic (15.37s)
=== RUN   TestAccAWSSQSQueuePolicy_import
--- PASS: TestAccAWSSQSQueuePolicy_import (15.93s)
PASS
ok  	github.com/terraform-providers/terraform-provider-aws/aws	31.348s

@@ -48,20 +52,20 @@ func resourceAwsSqsQueuePolicyUpsert(d *schema.ResourceData, meta interface{}) e
return fmt.Errorf("Error updating SQS attributes: %s", err)
}

d.SetId("sqs-policy-" + url)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@radeksimko Do you recall why this was set as is?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think there was a strong reason - maybe just to separate it from SQS queue IDs, but really we don't need to do that.

However I'd be cautious about changing the ID here in this context. Can you please verify this actually works for existing SQS policy which is already in state with the old ID? I suspect refresh might fail because it will try to read queue attributes for queue URL sqs-policy-"+url.

In other words I believe we need state migration.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @radeksimko, are you referring to something different than my state migration implementation?

MigrateState:  resourceAwsSqsQueuePolicyMigrateState,
SchemaVersion: 1,

If there's a better way to handle that, please let me know!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

doh 🤦‍♂️ sorry! I missed that one... In that case it's all good! Thanks.

@radeksimko
Copy link
Member

One thing I wanted to add (also to explain the upstream-terraform label) - we have some bigger plans around imports in the core to address the problem of "importing by multiple different fields" in provider/resource-agnostic way.

I cannot share any timelines around that, but I'd suggest we avoid spending more time on resource-specific solutions for the time being.

@radeksimko radeksimko merged commit 37cb271 into hashicorp:master Dec 11, 2017
psyvision added a commit to psyvision/terraform-provider-aws that referenced this pull request Dec 12, 2017
* Add Data Source: aws_elb

* Fix dataSourceAwsElb typo

* Fix dataSourceAwsElb Schema name field to not include Computed

* Remove dataSourceAwsElb schema defaults for computed fields

* Remove dataSourceAwsElb schema defaults for nested computed fields too

* Corrected depends_on entry for EIP

  depends_on                = ["aws_internet_gateway.gw"] is the correct syntax

* Add sweeper for IAM Server Certificates

* test/aws_config_delivery_channel: Add missing dependencies

* d/aws_elb r/aws_elb: hashicorp#2004 review comments

* Remove enable_deletion_protection from testAccDataSourceAWSELBConfigBasic
* Replace unnecessary errwrap.Wrapf with fmt.Errorf
* Reduce flattenAwsELbResource to ec2conn and elbconn instead of meta
* Properly name TestAccDataSourceAWSELB_basic resources
* Use t.Name() for description and TestName tags

* d/aws_elb: Fix documentation sidebar ordering after merging master with new d/aws_elasticache_replication_group

* Makefile: Add sweep target

* Update cognito_user_pool.markdown

* Update CHANGELOG.md

* r/aws_elasticache_security_group: add import support (hashicorp#2277)

* r/aws_elasticache_security_group: add import support

* r/aws_elasticache_security_group: hashicorp#2277 review updates

* Use d.Id() instead of d.Get("name") on read, which allows using schema.ImportStatePassthrough
* d.Set("security_group_names") on read
* Set AWS_DEFAULT_REGION to us-east-1 on import testing

* Update CHANGELOG.md

* documentation: remove antislashes in page titles

* Added missing WARN debug lines when reading a non-existing resource

* Removed <wbr> from documentation titles

* vendor: Bump aws-sdk-go to v.1.12.44

* Add logs for iam server certificate delete conflict (hashicorp#2533)

* Query elb API for load balancer arn causing delete conflict

- For IAM server certificate.

* Use regex for lb name.

* Edits for hashicorp#2533

* r/aws_sqs_queue_policy: Support import by queue URL (hashicorp#2544)

* Update CHANGELOG.md

* r/aws_elasticsearch_domain: Add LogPublishingOption (hashicorp#2285)

* WIP

* Add enabled

* Use cwl policy

* Reflect reviews

* Update CHANGELOG.md

* Add force_destroy field to aws_athena_database (hashicorp#2363)

* Add force_destroy field to aws_athena_database.

Fixes hashicorp#2362.

* Remove unnecessary import.

* Code review feedback

* Update CHANGELOG.md

* Add more example and missing field

* New Resource: aws_media_store_container (hashicorp#2448)

* New Resource: aws_media_store_container

* Reflect reviews

* remove policy

* Update CHANGELOG.md

* Add Redis AUTH, in-transit and at-rest encryption (hashicorp#2090)

* add AUTH, at-rest and in-transit encryption to Elasticache replication groups

* add _enabled to transit/at_rest encyrption parameters

* added one more _enabled

* move validateAwsElastiCacheReplicationGroupAuthToken to aws/validators.go, as well as tests

* set auth_token to nil during Reads

* update Replication Group encryption acceptance tests to use config functions instead of vars

* Fix whitespacing (tabs -> spaces)

* docs/elasticache_replication_group: Add missing fields

* Update CHANGELOG.md

* r/aws_dynamodb_table: Ensure ttl is properly read (hashicorp#2452)

* r/aws_dynamodb_table: Ensure ttl is properly read

* r/aws_dynamodb_table: hashicorp#2452 review updates

* Add timeToLiveOutput.TimeToLiveDescription nil check
* Simplify logic to d.Set ttl

* Update CHANGELOG.md

* Bump aws-sdk-go to v.1.12.45

* New Resource: PublicDnsNamespace (hashicorp#2569)

* WIP

* Add test, docs

* Reflect reviews

* Modify error handling

* Update CHANGELOG.md

* New Resource: ServiceDiscovery PrivateDNS Namespace (hashicorp#2589)

* New Resource: service_discovery_private_dns_namespace

* Reflect reviews

* Update CHANGELOG.md
@ghost
Copy link

ghost commented Apr 10, 2020

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thanks!

@ghost ghost locked and limited conversation to collaborators Apr 10, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement Requests to existing resources that expand the functionality or scope. upstream-terraform Addresses functionality related to the Terraform core binary.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Feature Request: import support for aws_sqs_queue_policy
3 participants