in GameLiftPlugin/Source/GameLiftPlugin/Private/SMenu/EC2/SDeployScenarioSection.cpp [201:296]
FReply SDeployScenarioSection::DeployCloudFormation()
{
if (Paths::DefaultOutConfigFilePath() != AsSDeploymentFieldsRef(DeploymentFields)->GetOutConfigFilePath().ToString())
{
UE_LOG(GameLiftPluginLog, Warning, TEXT("%s"), Menu::DeployManagedEC2::Logs::kOutputPathChangedWarning);
}
if (IsDeploymentStatusActive())
{
auto choice = FMessageDialog::Open(EAppMsgType::YesNo, Menu::DeployManagedEC2::kConfirmReploymentText);
if (choice != EAppReturnType::Yes) {
return FReply::Handled();
}
}
SetProgressBarState(SProgressBar::EProgressBarUIState::InProgress);
AsSDeploymentStatusRef(DeploymentStatus)->OnDeploy();
SetUGameLiftDeploymentStatus(EDeploymentMessageState::InProgressMessage);
OnEC2DeploymentProgressChangedMultiDelegate.Broadcast();
auto DeploymentInfo = AsSDeploymentFieldsRef(DeploymentFields);
UGameLiftDeploymentStatus* DeploySettings = GetMutableDefault<UGameLiftDeploymentStatus>();
DeploySettings->BuildName = DeploymentInfo->GetBuildName();
DeploySettings->BuildOperatingSystem = DeploymentInfo->GetBuildOperatingSystem();
DeploySettings->BuildFolderPath = DeploymentInfo->GetBuildFolderPath();
DeploySettings->BuildFilePath = DeploymentInfo->GetBuildFilePath();
DeploySettings->ExtraServerResourcesPath = DeploymentInfo->GetExtraServerResourcesPath();
DeploySettings->OutConfigFilePath = DeploymentInfo->GetOutConfigFilePath();
DeploySettings->Scenario = DeploymentInfo->GetDeploymentScenario();
UGameLiftSettings* Settings = GetMutableDefault<UGameLiftSettings>();
DeploySettings->DeployedRegion = Settings->AwsRegion;
DeploySettings->ApiGatewayEndpoint = FText::GetEmpty();
DeploySettings->CognitoClientId = FText::GetEmpty();
DeploySettings->SaveConfig();
FText NotifyMessage = FText::GetEmpty();
NotifyMessage = FText::Format(LOCTEXT("DeploymentNotificationAws", "{0}\n{1}"),
FText::FromString(Menu::DeployManagedEC2::kDeploymentStartedAwsScenarioNotification), DeploySettings->Scenario);
NotificationItem = Notifier::CreateNotification(NotifyMessage);
Async(EAsyncExecution::Thread, [this, NotificationItem = NotificationItem] () mutable
{
UGameLiftDeploymentStatus* DeploySettings = GetMutableDefault<UGameLiftDeploymentStatus>();
auto& deployer = IGameLiftCoreModule::Get().GetScenarioDeployer();
// Pass in StackIdentifier for the GameName field in the deployer as a quick workaround
// to decouple containers and ec2 stack deployments and fix describe container fleet calls
FString HostingSolution = "-ManagedEC2";
DeploySettings->StackIdentifier = DeploySettings->BuildName.ToString() + HostingSolution;
bool IsDeployed = deployer.DeployManagedEC2Scenario(
DeploySettings->Scenario,
IGameLiftCoreModule::Get().GetProfileBootstrap().GetAccountInstance(),
DeploySettings->StackIdentifier,
DeploySettings->BuildOperatingSystem.ToString(),
DeploySettings->BuildFolderPath.ToString(),
DeploySettings->BuildFilePath.ToString(),
DeploySettings->OutConfigFilePath.ToString(),
DeploySettings->ExtraServerResourcesPath.ToString()
);
if (IsDeployed)
{
UE_LOG(GameLiftPluginLog, Display, TEXT("%s"), Menu::DeployManagedEC2::Logs::kDeploymentSucceed);
DeploySettings->ApiGatewayEndpoint = FText::FromString(deployer.GetLastApiGatewayEndpoint());
DeploySettings->CognitoClientId = FText::FromString(deployer.GetLastCognitoClientId());
SetUGameLiftDeploymentStatus(EDeploymentMessageState::ActiveMessage);
Notifier::CompleteWithSuccess(NotificationItem, Menu::DeployManagedEC2::kDeploymentCompletedNotification);
}
else
{
UE_LOG(GameLiftPluginLog, Display, TEXT("%s"), Menu::DeployManagedEC2::Logs::kDeploymentFailed);
DeploySettings->LatestError = Utils::BuildLastestErrorMessage(deployer);
SetUGameLiftDeploymentStatus(EDeploymentMessageState::FailureMessage);
Notifier::CompleteWithFailure(NotificationItem, Menu::DeployManagedEC2::kDeploymentFailedNotification);
}
DeploySettings->SaveConfig();
Async(EAsyncExecution::TaskGraphMainThread,
[this]
{
UpdateUIBasedOnCurrentState();
});
});
return FReply::Handled();
}