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

Initial pass at interactive aws provider #178

Merged
merged 5 commits into from
Aug 2, 2016

Conversation

mwildehahn
Copy link
Contributor

Not ready to merge, but wanted to get it out there to start some discussion around the output:

Right now it looks like:

$ ./bin/test-empire build
stacker build conf/empire/example.env conf/empire/empire.yaml --env namespace=mh.empire.dev --env external_domain=empire.com --env ssh_key_name=remind-us-east-1 --env trusted_network_cidr=0.0.0.0/0 --env docker_registry_user=mhahn --env docker_registry_email=mwhahn@gmail.com --env docker_registry_password=aT4Okzn{wbe3SoO8Z --env empiredb_user=empire --env empiredb_password=SomePasswordHere22 --env empire_controller_token_secret=oi234lk2j432lk4j22oiA --env empire_environment=dev
[2016-07-28T13:26:13] Executing pre_build hooks: stacker.hooks.route53.create_domain
[2016-07-28T13:26:14] Launching stacks: mh-empire-dev-vpc, mh-empire-dev-bastion, mh-empire-dev-empireMinion, mh-empire-dev-empireDB, mh-empire-dev-empireController, mh-empire-dev-empireDaemon, mh-empire-dev-acmeApp

Cloudformation wants to make the following changes to stack: mh-empire-dev-empireDaemon

- ResourceChange:
    Action: Modify
    Details:
    - CausingEntity: TaskDefinition
      ChangeSource: ResourceReference
      Evaluation: Static
      Target: {Attribute: Properties, Name: TaskDefinition, RequiresRecreation: Never}
    LogicalResourceId: Service
    PhysicalResourceId: arn:aws:ecs:us-east-1:935008130000:service/mh-empire-dev-empireDaemon-Service-1KBHNP1GPSF5H
    Replacement: 'False'
    ResourceType: AWS::ECS::Service
    Scope: [Properties]
  Type: Resource
- ResourceChange:
    Action: Modify
    Details:
    - CausingEntity: TaskMemory
      ChangeSource: ParameterReference
      Evaluation: Static
      Target: {Attribute: Properties, Name: ContainerDefinitions, RequiresRecreation: Always}
    - ChangeSource: DirectModification
      Evaluation: Dynamic
      Target: {Attribute: Properties, Name: ContainerDefinitions, RequiresRecreation: Always}
    LogicalResourceId: TaskDefinition
    PhysicalResourceId: arn:aws:ecs:us-east-1:935008130000:task-definition/mh-empire-dev-empireDaemon-TaskDefinition-1WGARY55GXE62:1
    Replacement: 'True'
    ResourceType: AWS::ECS::TaskDefinition
    Scope: [Properties]
  Type: Resource

Execute the above changes? [y/n] y
[2016-07-28T13:32:58] Updating existing stack: mh-empire-dev-empireDaemon
[2016-07-28T13:32:58] Plan Status:
[2016-07-28T13:32:58]   - step "mh-empire-dev-vpc": skipped (nochange)
[2016-07-28T13:32:58]   - step "mh-empire-dev-bastion": skipped (nochange)
[2016-07-28T13:32:58]   - step "mh-empire-dev-empireMinion": skipped (nochange)
[2016-07-28T13:32:58]   - step "mh-empire-dev-empireDB": skipped (locked)
[2016-07-28T13:32:58]   - step "mh-empire-dev-empireController": skipped (nochange)
[2016-07-28T13:32:58]   - step "mh-empire-dev-empireDaemon": submitted (updating existing stack)
[2016-07-28T13:32:58]   - step "mh-empire-dev-acmeApp": pending
[2016-07-28T13:33:44] Plan Status:
[2016-07-28T13:33:44]   - step "mh-empire-dev-vpc": skipped (nochange)
[2016-07-28T13:33:44]   - step "mh-empire-dev-bastion": skipped (nochange)
[2016-07-28T13:33:44]   - step "mh-empire-dev-empireMinion": skipped (nochange)
[2016-07-28T13:33:44]   - step "mh-empire-dev-empireDB": skipped (locked)
[2016-07-28T13:33:44]   - step "mh-empire-dev-empireController": skipped (nochange)
[2016-07-28T13:33:44]   - step "mh-empire-dev-empireDaemon": submitted (updating existing stack)
[2016-07-28T13:33:44]   - step "mh-empire-dev-acmeApp": pending
[2016-07-28T13:34:35] Plan Status:
[2016-07-28T13:34:35]   - step "mh-empire-dev-vpc": skipped (nochange)
[2016-07-28T13:34:35]   - step "mh-empire-dev-bastion": skipped (nochange)
[2016-07-28T13:34:35]   - step "mh-empire-dev-empireMinion": skipped (nochange)
[2016-07-28T13:34:35]   - step "mh-empire-dev-empireDB": skipped (locked)
[2016-07-28T13:34:35]   - step "mh-empire-dev-empireController": skipped (nochange)
[2016-07-28T13:34:35]   - step "mh-empire-dev-empireDaemon": submitted (updating existing stack)
[2016-07-28T13:34:35]   - step "mh-empire-dev-acmeApp": pending
[2016-07-28T13:34:43] Plan Status:
[2016-07-28T13:34:43]   - step "mh-empire-dev-vpc": skipped (nochange)
[2016-07-28T13:34:43]   - step "mh-empire-dev-bastion": skipped (nochange)
[2016-07-28T13:34:43]   - step "mh-empire-dev-empireMinion": skipped (nochange)
[2016-07-28T13:34:43]   - step "mh-empire-dev-empireDB": skipped (locked)
[2016-07-28T13:34:43]   - step "mh-empire-dev-empireController": skipped (nochange)
[2016-07-28T13:34:43]   - step "mh-empire-dev-empireDaemon": complete (updating existing stack)
[2016-07-28T13:34:43]   - step "mh-empire-dev-acmeApp": skipped (nochange)

I'm going to play with some cli libraries to see if I can come up with something cleaner.

@mwildehahn
Copy link
Contributor Author

I updated this a little bit:

stacker build conf/empire/example.env conf/empire/empire.yaml -i --env namespace=mh.empire.dev --env external_domain=empire.com --env ssh_key_name=remind-us-east-1 --env trusted_network_cidr=0.0.0.0/0 --env docker_registry_user=mhahn --env docker_registry_email=mwhahn@gmail.com --env docker_registry_password=aT4Okzn{wbe3SoO8Z --env empiredb_user=empire --env empiredb_password=SomePasswordHere22 --env empire_controller_token_secret=oi234lk2j432lk4j22oiA --env empire_environment=dev
[2016-08-01T12:31:00] Using Interactive AWS Provider
[2016-08-01T12:31:00] Executing pre_build hooks: stacker.hooks.route53.create_domain
[2016-08-01T12:31:00] Launching stacks: mh-empire-dev-vpc, mh-empire-dev-bastion, mh-empire-dev-empireMinion, mh-empire-dev-empireDB, mh-empire-dev-empireController, mh-empire-dev-empireDaemon, mh-empire-dev-acmeApp
[2016-08-01T12:32:17] Cloudformation wants to make the following changes to stack: mh-empire-dev-empireDaemon
- ResourceChange:
    Action: Modify
    Details:
    - CausingEntity: TaskDefinition
      ChangeSource: ResourceReference
      Evaluation: Static
      Target: {Attribute: Properties, Name: TaskDefinition, RequiresRecreation: Never}
    LogicalResourceId: Service
    PhysicalResourceId: arn:aws:ecs:us-east-1:935008130000:service/mh-empire-dev-empireDaemon-Service-1KBHNP1GPSF5H
    Replacement: 'False'
    ResourceType: AWS::ECS::Service
    Scope: [Properties]
  Type: Resource
- ResourceChange:
    Action: Modify
    Details:
    - CausingEntity: TaskMemory
      ChangeSource: ParameterReference
      Evaluation: Static
      Target: {Attribute: Properties, Name: ContainerDefinitions, RequiresRecreation: Always}
    - ChangeSource: DirectModification
      Evaluation: Dynamic
      Target: {Attribute: Properties, Name: ContainerDefinitions, RequiresRecreation: Always}
    LogicalResourceId: TaskDefinition
    PhysicalResourceId: arn:aws:ecs:us-east-1:935008130000:task-definition/mh-empire-dev-empireDaemon-TaskDefinition-15PTMLRB3SLUM:1
    Replacement: 'True'
    ResourceType: AWS::ECS::TaskDefinition
    Scope: [Properties]
  Type: Resource

Execute the above changes? [y/n] n
[2016-08-01T12:32:32] Cancelling execution

I'm going to implement some alternative outputs, but I'll do them in a separate PR since the core of this one should just be the implementation of the interactive provider.

Now you can specify stacker build ---interactive (-i) to run with the interactive provider.

Right now interactive builds display each change set. I'm going to change this in a separate PR so by default we only display when the change set requires a replacement.

I'll then add a --strict flag which someone can use if they want to approve all changes.

@mwildehahn
Copy link
Contributor Author

mwildehahn commented Aug 1, 2016

https://github.com/mhahn/stacker/pull/1/files

I'll submit that against this one when this is merged. Adds the "verbose" option that you had mentioned. By default we'll only list out the replacements, but you can provide "v" to list out all the changes:

[2016-08-01T13:25:22] Using Interactive AWS Provider
[2016-08-01T13:25:22] Executing pre_build hooks: stacker.hooks.route53.create_domain
[2016-08-01T13:25:22] Launching stacks: mh-empire-dev-vpc, mh-empire-dev-bastion, mh-empire-dev-empireMinion, mh-empire-dev-empireDB, mh-empire-dev-empireController, mh-empire-dev-empireDaemon, mh-empire-dev-acmeApp
[2016-08-01T13:25:44] Cloudformation wants to make the following replacements to stack: mh-empire-dev-empireDaemon
- ResourceChange:
    Action: Modify
    Details:
    - CausingEntity: TaskMemory
      ChangeSource: ParameterReference
      Evaluation: Static
      Target: {Attribute: Properties, Name: ContainerDefinitions, RequiresRecreation: Always}
    - ChangeSource: DirectModification
      Evaluation: Dynamic
      Target: {Attribute: Properties, Name: ContainerDefinitions, RequiresRecreation: Always}
    LogicalResourceId: TaskDefinition
    PhysicalResourceId: arn:aws:ecs:us-east-1:935008130000:task-definition/mh-empire-dev-empireDaemon-TaskDefinition-20550DOSS2SU:1
    Replacement: 'True'
    ResourceType: AWS::ECS::TaskDefinition
    Scope: [Properties]
  Type: Resource

Execute the above changes? [y/n/v] v
[2016-08-01T13:25:51] Full changeset:
- ResourceChange:
    Action: Modify
    Details:
    - CausingEntity: TaskDefinition
      ChangeSource: ResourceReference
      Evaluation: Static
      Target: {Attribute: Properties, Name: TaskDefinition, RequiresRecreation: Never}
    LogicalResourceId: Service
    PhysicalResourceId: arn:aws:ecs:us-east-1:935008130000:service/mh-empire-dev-empireDaemon-Service-195N0FM69OP2A
    Replacement: 'False'
    ResourceType: AWS::ECS::Service
    Scope: [Properties]
  Type: Resource
- ResourceChange:
    Action: Modify
    Details:
    - CausingEntity: TaskMemory
      ChangeSource: ParameterReference
      Evaluation: Static
      Target: {Attribute: Properties, Name: ContainerDefinitions, RequiresRecreation: Always}
    - ChangeSource: DirectModification
      Evaluation: Dynamic
      Target: {Attribute: Properties, Name: ContainerDefinitions, RequiresRecreation: Always}
    LogicalResourceId: TaskDefinition
    PhysicalResourceId: arn:aws:ecs:us-east-1:935008130000:task-definition/mh-empire-dev-empireDaemon-TaskDefinition-20550DOSS2SU:1
    Replacement: 'True'
    ResourceType: AWS::ECS::TaskDefinition
    Scope: [Properties]
  Type: Resource

@mwildehahn mwildehahn mentioned this pull request Aug 1, 2016
@@ -242,6 +246,9 @@ def execute(self):
if attempts == 1:
self._check_point()
self._wait_func(self.sleep_time)
except CancelExecution:
logger.info("Cancelling execution")
Copy link
Member

Choose a reason for hiding this comment

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

Worth including the plan step here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

i'll keep this in mind, i might make some changes to the output, i'll take a look at this then

@phobologic
Copy link
Member

Looks good other than my comments, thanks.


from ... import exceptions
from .default import (
Provider as BaseProvider,
Copy link
Member

Choose a reason for hiding this comment

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

AWSProvider maybe instead.

@mwildehahn mwildehahn merged commit 4fc631e into cloudtools:master Aug 2, 2016
@mwildehahn mwildehahn deleted the change-sets branch August 2, 2016 23:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants