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

providers/aws: Opsworks permission resource #6304

Merged
merged 12 commits into from
Jul 20, 2016
Merged

providers/aws: Opsworks permission resource #6304

merged 12 commits into from
Jul 20, 2016

Conversation

janschumann
Copy link
Contributor

@janschumann janschumann commented Apr 22, 2016

The code in this PR works, but unfortunately the tests fail, complaining that aws_opsworks_permission.tf-acc-perm could not be found.

Also I am not sure if I have implemented it correctly. E.g. I had to implement a Delete function although this resource cannot be deleted. I left the delete function empty ...

}
}

func resourceAwsOpsworksPermissionDelete(d *schema.ResourceData, meta interface{}) error {
Copy link
Contributor

Choose a reason for hiding this comment

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

is there no delete functionality here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes. There is no delete. Also create is not really there, as permissions objects are created on creation of the stack. These are crated with default values an can than be changed.

@u2mejc
Copy link
Contributor

u2mejc commented May 28, 2016

Hi guys! Happy friday! What's the status of this? @stack72 Anything else you would like to see changed before we can have it merged?

:shipit:

@u2mejc
Copy link
Contributor

u2mejc commented Jun 1, 2016

Morning guys! @stack72 are you still able to take a look at this, or should we see if @apparentlymart has time?

if awserr.Code() == "ResourceNotFoundException" {
log.Printf("[INFO] Permission not found")
d.SetId("")
d.Set("id", "")
Copy link
Contributor

Choose a reason for hiding this comment

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

We don't need this - the SetId("") takes care of it :)

@stack72
Copy link
Contributor

stack72 commented Jun 2, 2016

Hi @janschumann

Apologies for this slipping through the cracks (thanks @u2mejc for the reminder!)

I have just ran the tests (after leaving a few more small comments). The test fails I am afraid

make testacc TEST=./builtin/providers/aws TESTARGS='-run=TestAccAWSOpsworksPermission'
==> Checking that code complies with gofmt requirements...
/Users/stacko/Code/go/bin/stringer
go generate $(go list ./... | grep -v /vendor/)
2016/06/02 01:10:13 Generated command/internal_plugin_list.go
TF_ACC=1 go test ./builtin/providers/aws -v -run=TestAccAWSOpsworksPermission -timeout 120m
=== RUN   TestAccAWSOpsworksPermission
--- FAIL: TestAccAWSOpsworksPermission (142.00s)
    testing.go:239: Step 0 error: Error applying: 1 error(s) occurred:

        * aws_opsworks_permission.tf-acc-perm: ResourceNotFoundException: Unable to find user with ARN arn:aws:iam::881237884953:user/test-user
            status code: 400, request id: b94c910a-2856-11e6-9260-019c62f4ef41
FAIL
exit status 1
FAIL    github.com/hashicorp/terraform/builtin/providers/aws    142.019s
make: *** [testacc] Error 1

this is because of this line in the test code:

user_arn = "${aws_iam_user.user.arn}"

We are not creating that test user as part of the test - once this gets created, they should pass. So close to being ready for merge here!

Thanks

Paul

@stack72 stack72 self-assigned this Jun 2, 2016
@stack72 stack72 added the waiting-response An issue/pull request is waiting for a response from the community label Jun 2, 2016
@stack72
Copy link
Contributor

stack72 commented Jun 10, 2016

Hi @janschumann

Any thoughts on how we get the tests for this resource working as expected?

Paul

@janschumann
Copy link
Contributor Author

Jepp sorry, I have them working already. Hope I will find time for the finish during the next few days.

Best, Jan

@janschumann
Copy link
Contributor Author

Now I was able to interpret what the failing test tells us: The user which is referenced by ${aws_iam_user.user.arn} is created. But that user has to be imported to OpsWorks via another resource wich is referred to as UserProfile within the aws sdk.

Sorry for the confusion and the delay here!

I will replace resourceAwsOpsworksPermission with resourceAwsOpsworksUserProfile. A permission is not a resource, but a configuration for the user profile.

@janschumann
Copy link
Contributor Author

I will add doc for user_profile later today

@stack72
Copy link
Contributor

stack72 commented Jun 14, 2016

Hi @janschumann

Testing this right now :)

Paul

client := meta.(*AWSClient).opsworksconn

req := &opsworks.CreateUserProfileInput{
AllowSelfManagement: aws.Bool(d.Get("allow_self_management").(bool)),
Copy link
Contributor

Choose a reason for hiding this comment

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

As this is an optional param, with no default, what will happen here if there is no value set?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@stack72 unfortunately the AWS documentation does not mention a default value, but as you can see in the test, the AWS default is false. Should I add Computed: true to that parameter?

Copy link
Contributor

Choose a reason for hiding this comment

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

I personally would skip the Computed and add Default: false to the schema. That way we can guarantee that we have a value and d.GetOk will not fail to get a value

Copy link
Contributor Author

Choose a reason for hiding this comment

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

check. default value added.

@stack72
Copy link
Contributor

stack72 commented Jul 5, 2016

thanks @janschumann

will run these tests really soon - just testing something else first!

P.

@stack72 stack72 merged commit ecb4b5a into hashicorp:master Jul 20, 2016
@ghost
Copy link

ghost commented Apr 24, 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 have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@ghost ghost locked and limited conversation to collaborators Apr 24, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
provider/aws waiting-response An issue/pull request is waiting for a response from the community
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants