Skip to content

Commit

Permalink
fix: container based deployments on native projects (#6201)
Browse files Browse the repository at this point in the history
  • Loading branch information
elorzafe committed Jan 6, 2021
1 parent 6ebbe41 commit 5ebcae8
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,13 @@ function constructApi(metadata, amplifyConfig) {
region,
authorizationType: 'AWS_IAM',
};
} else if (resourceMeta.service === 'ElasticContainer' && resourceMeta.apiType === 'REST') {
amplifyConfig[categoryName].plugins[pluginName][r] = {
endpointType: 'REST',
endpoint: resourceMeta.output.RootUrl,
region,
authorizationType: resourceMeta.restrictAccess ? "AMAZON_COGNITO_USER_POOLS" : "AWS_IAM",
};
}
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,13 @@ function constructApi(metadata, amplifyConfig) {
region,
authorizationType: 'AWS_IAM',
};
} else if (resourceMeta.service === 'ElasticContainer' && resourceMeta.apiType === 'REST') {
amplifyConfig[categoryName].plugins[pluginName][r] = {
endpointType: 'REST',
endpoint: resourceMeta.output.RootUrl,
region,
authorizationType: resourceMeta.restrictAccess ? "AMAZON_COGNITO_USER_POOLS" : "AWS_IAM",
};
}
}
});
Expand Down
7 changes: 7 additions & 0 deletions packages/amplify-frontend-ios/lib/amplify-config-helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,13 @@ function constructApi(metadata, amplifyConfig) {
region,
authorizationType: 'AWS_IAM',
};
} else if (resourceMeta.service === 'ElasticContainer' && resourceMeta.apiType === 'REST') {
amplifyConfig[categoryName].plugins[pluginName][r] = {
endpointType: 'REST',
endpoint: resourceMeta.output.RootUrl,
region,
authorizationType: resourceMeta.restrictAccess ? "AMAZON_COGNITO_USER_POOLS" : "AWS_IAM",
};
}
}
});
Expand Down
12 changes: 3 additions & 9 deletions packages/amplify-frontend-ios/lib/configuration-manager.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,13 @@
function init(context) {
return new Promise(resolve => {
resolve(context);
});
return Promise.resolve(context);
}

function onInitSuccessful(context) {
return new Promise(resolve => {
resolve(context);
});
return Promise.resolve(context);
}

function configure(context) {
return new Promise(resolve => {
resolve(context);
});
return Promise.resolve(context);
}

module.exports = {
Expand Down
24 changes: 6 additions & 18 deletions packages/amplify-frontend-javascript/lib/configuration-manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ async function init(context) {
framework,
config,
};
const initial = true;
await confirmConfiguration(context, initial);
await confirmConfiguration(context);
}

function onInitSuccessful(context) {
Expand All @@ -34,8 +33,7 @@ async function configure(context) {
currentConfiguration.config = getProjectConfiguration(currentConfiguration.framework, context.exeInfo.localEnvInfo.projectPath);
}

const initial = false;
await confirmConfiguration(context, initial);
await confirmConfiguration(context);
}

function normalizeInputParams(context) {
Expand Down Expand Up @@ -67,9 +65,9 @@ function normalizeInputParams(context) {
context.exeInfo.inputParams[constants.Label] = inputParams;
}

async function confirmConfiguration(context, initial = true) {
async function confirmConfiguration(context) {
await confirmFramework(context);
await confirmFrameworkConfiguration(context, initial);
await confirmFrameworkConfiguration(context);
}

async function confirmFramework(context) {
Expand Down Expand Up @@ -102,7 +100,7 @@ async function confirmFramework(context) {
}
}

async function confirmFrameworkConfiguration(context, initial = true) {
async function confirmFrameworkConfiguration(context) {
const inputParams = context.exeInfo.inputParams[constants.Label];
if (inputParams && inputParams.config) {
Object.assign(context.exeInfo.projectConfig[constants.Label].config, inputParams.config);
Expand Down Expand Up @@ -142,17 +140,7 @@ async function confirmFrameworkConfiguration(context, initial = true) {
];
const answers = await inquirer.prompt(configurationSettings);

let ServerlessContainers;
if (!initial) {
({ ServerlessContainers } = await inquirer.prompt({
type: 'confirm',
name: 'ServerlessContainers',
message: 'Do you want to enable container-based deployments?',
default: config.ServerlessContainers === true
}));
}

Object.assign(context.exeInfo.projectConfig[constants.Label].config, { ...answers, ServerlessContainers });
Object.assign(context.exeInfo.projectConfig[constants.Label].config, { ...answers });
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,12 +82,32 @@ export async function configure(context: $TSContext) {
context.exeInfo = context.exeInfo || context.amplify.getProjectDetails();
normalizeInputParams(context);
context.exeInfo.awsConfigInfo = getCurrentConfig(context);
await enableServerlessContainers(context);

await newUserCheck(context);
printInfo(context);
await setProjectConfigAction(context);
return await carryOutConfigAction(context);
}

async function enableServerlessContainers(context: $TSContext) {
const frontend = context.exeInfo.projectConfig.frontend;
const { config = {} } = context.exeInfo.projectConfig[frontend] || {};

const { ServerlessContainers } = await prompt({
type: 'confirm',
name: 'ServerlessContainers',
message: 'Do you want to enable container-based deployments?',
default: config.ServerlessContainers === true
});

if (!context.exeInfo.projectConfig[frontend]) {
context.exeInfo.projectConfig[frontend] = { config };
}

context.exeInfo.projectConfig[frontend].config = { ...config, ServerlessContainers };
}

function doesAwsConfigExists(context: $TSContext) {
let configExists = false;
const { envName } = context?.exeInfo?.localEnvInfo || context.amplify.getEnvInfo();
Expand Down

0 comments on commit 5ebcae8

Please sign in to comment.