mirror of https://github.com/kubernetes/kops.git
parent
d3fea46f7a
commit
bde69b5b3e
|
@ -75,8 +75,8 @@ func (b *IAMModelBuilder) Build(c *fi.ModelBuilderContext) error {
|
|||
|
||||
iamRole = &awstasks.IAMRole{
|
||||
Name: s(name),
|
||||
RoleType: s(b.InstanceGroupTypeName(role)),
|
||||
RolePolicyDocument: fi.WrapResource(rolePolicy),
|
||||
ExportWithID: s(strings.ToLower(string(role)) + "s"),
|
||||
}
|
||||
c.AddTask(iamRole)
|
||||
|
||||
|
|
|
@ -97,17 +97,13 @@ func (b *KopsModelContext) NameForDNSZone() string {
|
|||
}
|
||||
|
||||
func (b *KopsModelContext) IAMName(role kops.InstanceGroupRole) string {
|
||||
return b.InstanceGroupTypeName(role) + "s." + b.ClusterName()
|
||||
}
|
||||
|
||||
func (b *KopsModelContext) InstanceGroupTypeName(role kops.InstanceGroupRole) string {
|
||||
switch role {
|
||||
case kops.InstanceGroupRoleMaster:
|
||||
return "master"
|
||||
return "masters." + b.ClusterName()
|
||||
case kops.InstanceGroupRoleBastion:
|
||||
return "bastion"
|
||||
return "bastions." + b.ClusterName()
|
||||
case kops.InstanceGroupRoleNode:
|
||||
return "node"
|
||||
return "nodes." + b.ClusterName()
|
||||
|
||||
default:
|
||||
glog.Fatalf("unknown InstanceGroup Role: %q", role)
|
||||
|
|
|
@ -38,8 +38,10 @@ import (
|
|||
type IAMRole struct {
|
||||
ID *string
|
||||
Name *string
|
||||
RoleType *string
|
||||
RolePolicyDocument *fi.ResourceHolder // "inline" IAM policy
|
||||
|
||||
// ExportWithId will expose the name & ARN for reuse as part of a larger system. Only supported by terraform currently.
|
||||
ExportWithID *string
|
||||
}
|
||||
|
||||
var _ fi.CompareWithID = &IAMRole{}
|
||||
|
@ -196,8 +198,10 @@ func (_ *IAMRole) RenderTerraform(t *terraform.TerraformTarget, a, e, changes *I
|
|||
AssumeRolePolicy: policy,
|
||||
}
|
||||
|
||||
t.AddOutputVariable(*e.RoleType+"s_role_arn", terraform.LiteralProperty("aws_iam_role", *e.Name, "arn"))
|
||||
t.AddOutputVariable(*e.RoleType+"s_role_name", e.TerraformLink())
|
||||
if fi.StringValue(e.ExportWithID) != "" {
|
||||
t.AddOutputVariable(*e.ExportWithID+"_role_arn", terraform.LiteralProperty("aws_iam_role", *e.Name, "arn"))
|
||||
t.AddOutputVariable(*e.ExportWithID+"_role_name", e.TerraformLink())
|
||||
}
|
||||
|
||||
return t.RenderResource("aws_iam_role", *e.Name, tf)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue