-
Notifications
You must be signed in to change notification settings - Fork 4k
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
Conversation
There was a problem hiding this 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!
There was a problem hiding this 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...
/** | ||
* The role's Name | ||
*/ | ||
roleName: string; |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
this.roleArn = ArnUtils.fromComponents({ | ||
service: 'iam', | ||
resource: 'role' | ||
}); |
There was a problem hiding this comment.
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('/'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use ArnUtils.parse
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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", |
There was a problem hiding this comment.
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', |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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 '/'. |
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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(); | ||
}, | ||
|
There was a problem hiding this comment.
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)
This PR needs some additional work and a merge from |
@cmaurer closing for now. feel free to reopen when/if you wish to continue this work. |
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license.