Skip to content

Commit

Permalink
added service account inside vm (#17)
Browse files Browse the repository at this point in the history
* added service account inside vm

* Update yandex-sa-id usage text

Co-authored-by: GennadySpb <[email protected]>

* added yandex-sa-id to readme

Co-authored-by: GennadySpb <[email protected]>
  • Loading branch information
Wolfeg and GennadySpb authored Jul 17, 2021
1 parent 7666ace commit 02e4504
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 25 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ $ docker-machine create \
- `--yandex-platform-id`: ID of the hardware platform configuration
- `--yandex-preemptible`: Yandex.Cloud Instance preemptibility flag
- `--yandex-sa-key-file`: Yandex.Cloud Service Account key file
- `--yandex-sa-id`: Service account ID to attach to the instance
- `--yandex-security-groups`: Set security groups
- `--yandex-ssh-port`: SSH port
- `--yandex-ssh-user`: SSH username
Expand Down Expand Up @@ -79,6 +80,7 @@ $ docker-machine create \
| `--yandex-platform-id` | YC_PLATFORM_ID | standard-v1 |
| `--yandex-preemptible` | YC_PREEMPTIBLE | false |
| `--yandex-sa-key-file` | YC_SA_KEY_FILE | |
| `--yandex-sa-id` | YC_SA_ID | |
| `--yandex-security-groups` | YC_SECURITY_GROUPS | |
| `--yandex-ssh-port` | YC_SSH_PORT | 22 |
| `--yandex-ssh-user` | YC_SSH_USER | yc-user |
Expand Down
3 changes: 2 additions & 1 deletion driver/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,8 @@ func prepareInstanceCreateRequest(d *Driver, imageID string) *compute.CreateInst
SchedulingPolicy: &compute.SchedulingPolicy{
Preemptible: d.Preemptible,
},
Metadata: d.Metadata,
ServiceAccountId: d.ServiceAccountID,
Metadata: d.Metadata,
}

if d.Nat {
Expand Down
55 changes: 31 additions & 24 deletions driver/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,30 +28,31 @@ type Driver struct {
ServiceAccountKeyFile string
Token string

CloudID string
Cores int
CoreFraction int
DiskSize int
DiskType string
FolderID string
ImageFamily string
ImageFolderID string
ImageID string
InstanceID string
Labels []string
Memory int
Metadata map[string]string
Nat bool
PlatformID string
Preemptible bool
SSHUser string
SubnetID string
UseIPv6 bool
UseInternalIP bool
UserDataFile string
Zone string
StaticAddress string
SecurityGroups []string
CloudID string
Cores int
CoreFraction int
DiskSize int
DiskType string
FolderID string
ImageFamily string
ImageFolderID string
ImageID string
InstanceID string
Labels []string
Memory int
Metadata map[string]string
Nat bool
PlatformID string
Preemptible bool
SSHUser string
SubnetID string
UseIPv6 bool
UseInternalIP bool
UserDataFile string
Zone string
StaticAddress string
SecurityGroups []string
ServiceAccountID string
}

const (
Expand Down Expand Up @@ -229,6 +230,11 @@ func (d *Driver) GetCreateFlags() []mcnflag.Flag {
Name: "yandex-security-groups",
Usage: "Set security groups",
},
mcnflag.StringFlag{
EnvVar: "YC_SA_ID",
Name: "yandex-sa-id",
Usage: "Service account ID to attach to the instance",
},
}
}

Expand Down Expand Up @@ -267,6 +273,7 @@ func (d *Driver) SetConfigFromFlags(flags drivers.DriverOptions) error {
d.Zone = flags.String("yandex-zone")
d.StaticAddress = flags.String("yandex-static-address")
d.SecurityGroups = flags.StringSlice("yandex-security-groups")
d.ServiceAccountID = flags.String("yandex-sa-id")

return nil
}
Expand Down

0 comments on commit 02e4504

Please sign in to comment.