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

feat(aws-iam): add aws iam instance profile: fixes #1223 #1224

Closed
wants to merge 11 commits into from

Conversation

cmaurer
Copy link

@cmaurer cmaurer commented Nov 21, 2018

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license.

Copy link
Contributor

@eladb eladb left a comment

Choose a reason for hiding this comment

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

Thanks for the contribution!

packages/@aws-cdk/aws-iam/lib/instance-profile.ts Outdated Show resolved Hide resolved
packages/@aws-cdk/aws-iam/lib/instance-profile.ts Outdated Show resolved Hide resolved
packages/@aws-cdk/aws-iam/lib/instance-profile.ts Outdated Show resolved Hide resolved
packages/@aws-cdk/aws-iam/test/test.instance-profile.ts Outdated Show resolved Hide resolved
Copy link
Contributor

@eladb eladb left a comment

Choose a reason for hiding this comment

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

A few more requests that I missed last time...

packages/@aws-cdk/aws-iam/README.md Show resolved Hide resolved
packages/@aws-cdk/aws-iam/lib/instance-profile.ts Outdated Show resolved Hide resolved
packages/@aws-cdk/aws-iam/lib/instance-profile.ts Outdated Show resolved Hide resolved
packages/@aws-cdk/aws-iam/lib/instance-profile.ts Outdated Show resolved Hide resolved
packages/@aws-cdk/aws-iam/lib/instance-profile.ts Outdated Show resolved Hide resolved
/**
* The role's Name
*/
roleName: string;
Copy link
Contributor

Choose a reason for hiding this comment

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

I am not sure that making both ARN and name required is the best developer experience. In many cases one can be deduced from the other. See example in ECR, where both are actually optional and one is deduced from the other in certain cases.

Not 100% sure that's the ideal situation, but I wouldn't want to require both if they can be deduced.

Copy link
Author

Choose a reason for hiding this comment

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

Sounds good. I will take a look.

@cmaurer cmaurer requested a review from a team as a code owner December 13, 2018 03:39
this.roleArn = ArnUtils.fromComponents({
service: 'iam',
resource: 'role'
});
Copy link
Contributor

Choose a reason for hiding this comment

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

Where is resourceName?

if (unresolved(this.roleArn)) {
throw new Error('roleArn is a late-bound value, and therefore roleName is required');
}
this.roleName = this.roleArn.split('/').slice(1).join('/');
Copy link
Contributor

Choose a reason for hiding this comment

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

Use ArnUtils.parse

Copy link
Author

Choose a reason for hiding this comment

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

@eladb
this.roleName is required (which I am pretty sure is correct), but its optional on ArnComponents, so I am getting the typescript error 'type string | undefined is not assignable...'. Thats why I used the split/slice/join. So, I am not sure what I should do here if the name is not supplied. undefined seems wrong, '' seems wrong, and making up a name seems wrong. I am probably missing something small, here.

Copy link
Author

Choose a reason for hiding this comment

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

nevermind, I think I figured it out.


/**
* Test Cases:
* parameters: role
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think this is necessary, and will likely become stale very quickly

Copy link
Author

Choose a reason for hiding this comment

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

this was my 'punch list', I will remove.

@@ -559,6 +559,7 @@ export class Table extends Construct {
private makeScalingRole(): iam.IRole {
// Use a Service Linked Role.
return iam.Role.import(this, 'ScalingRole', {
roleName: "DynamoDbAutoScalingRole",
Copy link
Contributor

Choose a reason for hiding this comment

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

revert

@@ -227,6 +227,7 @@ export abstract class BaseService extends cdk.Construct
private makeAutoScalingRole(): iam.IRole {
// Use a Service Linked Role.
return iam.Role.import(this, 'ScalingRole', {
roleName: 'ECSServiceAutoScalingRole',
Copy link
Contributor

Choose a reason for hiding this comment

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

revert

* @link http://docs.aws.amazon.com/IAM/latest/UserGuide/Using_Identifiers.html#Identifiers_FriendlyNames
* @default / By default, AWS CloudFormation specifies '/' for the path.
*/
path: string;
Copy link
Contributor

Choose a reason for hiding this comment

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

shouldn't that be optional?

import { InstanceProfileRef } from './instance-profile-ref';
import { PolicyStatement, ServicePrincipal } from './policy-document';
import { IRole, Role } from './role';
export interface InstanceProfileProps {
Copy link
Contributor

Choose a reason for hiding this comment

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

newline

/**
* Path for the Instance Profile
* @link http://docs.aws.amazon.com/IAM/latest/UserGuide/Using_Identifiers.html#Identifiers_FriendlyNames
* @default / If a path is not provided, CloudFormation defaults the path to '/'.
Copy link
Contributor

Choose a reason for hiding this comment

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

is it cfn that provides the default?

},
'import/export': {

'import with name'(test: Test) {
Copy link
Contributor

Choose a reason for hiding this comment

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

This is actually "import with an exported role"


test.done();
},

Copy link
Contributor

Choose a reason for hiding this comment

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

missing some cases here:

  • import with ARN token (failure)
  • import with name string (success)
  • import with name token (success)
  • import with ARN + name
  • import without ARN+name (failure)

@rix0rrr
Copy link
Contributor

rix0rrr commented Jan 15, 2019

This PR needs some additional work and a merge from master, unfortunately.

@rix0rrr rix0rrr added the response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days. label Jan 15, 2019
@eladb
Copy link
Contributor

eladb commented Feb 5, 2019

@cmaurer closing for now. feel free to reopen when/if you wish to continue this work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants