Configurable task execution role
Configurable task execution role https://docs.aws.amazon.com/AmazonECS/latest/developerguide/task_execution_IAM_role.html
This commit is contained in:
committed by
Robbie Zhang
parent
bb5dbdbd6e
commit
0a1acbc78e
@@ -41,6 +41,7 @@ type providerConfig struct {
|
|||||||
Subnets []string
|
Subnets []string
|
||||||
SecurityGroups []string
|
SecurityGroups []string
|
||||||
AssignPublicIPv4Address bool
|
AssignPublicIPv4Address bool
|
||||||
|
ExecutionRoleArn string
|
||||||
PlatformVersion string
|
PlatformVersion string
|
||||||
OperatingSystem string
|
OperatingSystem string
|
||||||
CPU string
|
CPU string
|
||||||
@@ -131,6 +132,7 @@ func (p *FargateProvider) loadConfig(r io.Reader) error {
|
|||||||
|
|
||||||
p.clusterName = config.ClusterName
|
p.clusterName = config.ClusterName
|
||||||
p.assignPublicIPv4Address = config.AssignPublicIPv4Address
|
p.assignPublicIPv4Address = config.AssignPublicIPv4Address
|
||||||
|
p.executionRoleArn = config.ExecutionRoleArn
|
||||||
p.platformVersion = config.PlatformVersion
|
p.platformVersion = config.PlatformVersion
|
||||||
p.operatingSystem = config.OperatingSystem
|
p.operatingSystem = config.OperatingSystem
|
||||||
p.capacity.cpu = config.CPU
|
p.capacity.cpu = config.CPU
|
||||||
|
|||||||
@@ -24,6 +24,10 @@ SecurityGroups = ["sg-12345678", "sg-87654321"]
|
|||||||
# Whether pod ENIs are assigned a public IPv4 address. Optional. Defaults to false.
|
# Whether pod ENIs are assigned a public IPv4 address. Optional. Defaults to false.
|
||||||
AssignPublicIPv4Address = false
|
AssignPublicIPv4Address = false
|
||||||
|
|
||||||
|
# Role assumed by AWS Fargate to execute your task. Optional.
|
||||||
|
# https://docs.aws.amazon.com/AmazonECS/latest/developerguide/task_execution_IAM_role.html
|
||||||
|
ExecutionRoleArn = ""
|
||||||
|
|
||||||
# Fargate platform version. Optional. Defaults to "LATEST".
|
# Fargate platform version. Optional. Defaults to "LATEST".
|
||||||
# https://docs.aws.amazon.com/AmazonECS/latest/developerguide/platform_versions.html
|
# https://docs.aws.amazon.com/AmazonECS/latest/developerguide/platform_versions.html
|
||||||
PlatformVersion = "LATEST"
|
PlatformVersion = "LATEST"
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ type ClusterConfig struct {
|
|||||||
Subnets []string
|
Subnets []string
|
||||||
SecurityGroups []string
|
SecurityGroups []string
|
||||||
AssignPublicIPv4Address bool
|
AssignPublicIPv4Address bool
|
||||||
|
ExecutionRoleArn string
|
||||||
PlatformVersion string
|
PlatformVersion string
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -32,6 +33,7 @@ type Cluster struct {
|
|||||||
subnets []string
|
subnets []string
|
||||||
securityGroups []string
|
securityGroups []string
|
||||||
assignPublicIPv4Address bool
|
assignPublicIPv4Address bool
|
||||||
|
executionRoleArn string
|
||||||
platformVersion string
|
platformVersion string
|
||||||
pods map[string]*Pod
|
pods map[string]*Pod
|
||||||
sync.RWMutex
|
sync.RWMutex
|
||||||
@@ -65,6 +67,7 @@ func NewCluster(config *ClusterConfig) (*Cluster, error) {
|
|||||||
subnets: config.Subnets,
|
subnets: config.Subnets,
|
||||||
securityGroups: config.SecurityGroups,
|
securityGroups: config.SecurityGroups,
|
||||||
assignPublicIPv4Address: config.AssignPublicIPv4Address,
|
assignPublicIPv4Address: config.AssignPublicIPv4Address,
|
||||||
|
executionRoleArn: config.ExecutionRoleArn,
|
||||||
platformVersion: config.PlatformVersion,
|
platformVersion: config.PlatformVersion,
|
||||||
pods: make(map[string]*Pod),
|
pods: make(map[string]*Pod),
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -80,6 +80,10 @@ func NewPod(cluster *Cluster, pod *corev1.Pod) (*Pod, error) {
|
|||||||
ContainerDefinitions: []*ecs.ContainerDefinition{},
|
ContainerDefinitions: []*ecs.ContainerDefinition{},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if cluster.executionRoleArn != "" {
|
||||||
|
taskDef.ExecutionRoleArn = aws.String(cluster.executionRoleArn)
|
||||||
|
}
|
||||||
|
|
||||||
// For each container in the pod...
|
// For each container in the pod...
|
||||||
for _, containerSpec := range pod.Spec.Containers {
|
for _, containerSpec := range pod.Spec.Containers {
|
||||||
// Create a container definition.
|
// Create a container definition.
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ type FargateProvider struct {
|
|||||||
clusterName string
|
clusterName string
|
||||||
capacity capacity
|
capacity capacity
|
||||||
assignPublicIPv4Address bool
|
assignPublicIPv4Address bool
|
||||||
|
executionRoleArn string
|
||||||
platformVersion string
|
platformVersion string
|
||||||
lastTransitionTime time.Time
|
lastTransitionTime time.Time
|
||||||
}
|
}
|
||||||
@@ -84,6 +85,7 @@ func NewFargateProvider(
|
|||||||
Subnets: p.subnets,
|
Subnets: p.subnets,
|
||||||
SecurityGroups: p.securityGroups,
|
SecurityGroups: p.securityGroups,
|
||||||
AssignPublicIPv4Address: p.assignPublicIPv4Address,
|
AssignPublicIPv4Address: p.assignPublicIPv4Address,
|
||||||
|
ExecutionRoleArn: p.executionRoleArn,
|
||||||
PlatformVersion: p.platformVersion,
|
PlatformVersion: p.platformVersion,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user