mirror of
https://github.com/floci-io/floci.git
synced 2026-11-23 14:10:49 -05:00
UpdateStack kept a reused AWS::EC2::Instance's prior UserData and IamInstanceProfile because Ec2Service had no in-place path for either: the provisioner reconciled only InstanceType and SecurityGroupIds. On AWS both are mutable, UserData with the "some interruptions" of a stop and a start. EC2 gains the three association actions, AssociateIamInstanceProfile, ReplaceIamInstanceProfileAssociation and DisassociateIamInstanceProfile, with botocore's wire names, all five members of the association including the timestamp the instance now records, and the errors moto documents (IncorrectState for a second association, InvalidAssociationID.NotFound for an unknown id). ModifyInstanceAttribute accepts UserData.Value on a stopped instance, answering IncorrectInstanceState otherwise, the order Terraform's provider performs as stop, modify, start. The association id derivation moves from the handler into Ec2Service so the provisioner can name an association. Ec2InstanceCfnProvisioner rewrites a changed UserData across a stop and a start (an already stopped instance stays stopped), resolves the profile name to its ARN at provision time as the RunInstances handler does, associates or replaces a changed profile, and disassociates one only when the template declared it last time, recorded in a __Floci attribute so a profile a launch template set is never stripped. A dropped UserData is left as it is, the same rule SecurityGroupIds follows. Tests: Ec2InstanceCfnProvisionerTest covers the stop/modify/start order, the stopped case, associate, replace, disassociate and the undeclared-profile guard; Ec2IamInstanceProfileAssociationIntegrationTest and Ec2UserDataAttributeIntegrationTest pin the wire behaviour; CloudFormationEc2InstanceIntegrationTest updates both properties on one instance and reads them back through EC2.